• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 "utils/rect.h"
19 #include "utils/scalar.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 
24 namespace OHOS {
25 namespace Rosen {
26 namespace Drawing {
27 class RectTest : public testing::Test {
28 public:
29     static void SetUpTestCase();
30     static void TearDownTestCase();
31     void SetUp() override;
32     void TearDown() override;
33 };
34 
SetUpTestCase()35 void RectTest::SetUpTestCase() {}
TearDownTestCase()36 void RectTest::TearDownTestCase() {}
SetUp()37 void RectTest::SetUp() {}
TearDown()38 void RectTest::TearDown() {}
39 
40 /**
41  * @tc.name: RectFCreateAndDestroy001
42  * @tc.desc:
43  * @tc.type: FUNC
44  * @tc.require:AR000GGNV3
45  * @tc.author:
46  */
47 HWTEST_F(RectTest, RectFCreateAndDestroy001, TestSize.Level1)
48 {
49     std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
50     EXPECT_EQ(0.0f, rectF->GetLeft());
51     EXPECT_EQ(0.0f, rectF->GetTop());
52     EXPECT_EQ(0.0f, rectF->GetRight());
53     EXPECT_EQ(0.0f, rectF->GetBottom());
54 }
55 
56 /**
57  * @tc.name: RectFCreateAndDestroy002
58  * @tc.desc:
59  * @tc.type: FUNC
60  * @tc.require:AR000GGNV3
61  * @tc.author:
62  */
63 HWTEST_F(RectTest, RectFCreateAndDestroy002, TestSize.Level1)
64 {
65     RectF rectf1;
66     rectf1.SetLeft(1.0f);
67     RectF rectf2(rectf1);
68     EXPECT_EQ(rectf1.GetLeft(), rectf2.GetLeft());
69 }
70 
71 /**
72  * @tc.name: RectFCreateAndDestroy003
73  * @tc.desc:
74  * @tc.type: FUNC
75  * @tc.require:AR000GGNV3
76  * @tc.author:
77  */
78 HWTEST_F(RectTest, RectFCreateAndDestroy003, TestSize.Level1)
79 {
80     RectF rectf1;
81     rectf1.SetLeft(2.0f);
82     RectF rectf2(rectf1);
83     EXPECT_EQ(rectf1.GetLeft(), rectf2.GetLeft());
84 }
85 
86 /**
87  * @tc.name: RectFCreateAndDestroy004
88  * @tc.desc:
89  * @tc.type: FUNC
90  * @tc.require:AR000GGNV3
91  * @tc.author:
92  */
93 HWTEST_F(RectTest, RectFCreateAndDestroy004, TestSize.Level1)
94 {
95     std::unique_ptr<RectF> rectF = std::make_unique<RectF>(1.0f, 2.0f, 3.0f, 4.0f);
96     EXPECT_EQ(1.0f, rectF->GetLeft());
97     EXPECT_EQ(2.0f, rectF->GetTop());
98     EXPECT_EQ(3.0f, rectF->GetRight());
99     EXPECT_EQ(4.0f, rectF->GetBottom());
100 }
101 
102 /**
103  * @tc.name: RectFCreateAndDestroy005
104  * @tc.desc:
105  * @tc.type: FUNC
106  * @tc.require:AR000GGNV3
107  * @tc.author:
108  */
109 HWTEST_F(RectTest, RectFCreateAndDestroy005, TestSize.Level1)
110 {
111     std::unique_ptr<RectF> rectF = std::make_unique<RectF>(4.0f, 3.0f, 2.0f, 1.0f);
112     EXPECT_EQ(4.0f, rectF->GetLeft());
113     EXPECT_EQ(3.0f, rectF->GetTop());
114     EXPECT_EQ(2.0f, rectF->GetRight());
115     EXPECT_EQ(1.0f, rectF->GetBottom());
116 }
117 
118 /**
119  * @tc.name: RectFIsValid001
120  * @tc.desc:
121  * @tc.type: FUNC
122  * @tc.require:AR000GGNV3
123  * @tc.author:
124  */
125 HWTEST_F(RectTest, RectFIsValid001, TestSize.Level1)
126 {
127     std::unique_ptr<RectF> rectF = std::make_unique<RectF>(4.0f, 3.0f, 2.0f, 1.0f);
128     EXPECT_FALSE(rectF->IsValid());
129 }
130 
131 /**
132  * @tc.name: RectFIsValid002
133  * @tc.desc:
134  * @tc.type: FUNC
135  * @tc.require:AR000GGNV3
136  * @tc.author:
137  */
138 HWTEST_F(RectTest, RectFIsValid002, TestSize.Level1)
139 {
140     std::unique_ptr<RectF> rectF = std::make_unique<RectF>(1.0f, 2.0f, 3.0f, 4.0f);
141     EXPECT_TRUE(rectF->IsValid());
142 }
143 
144 /**
145  * @tc.name: RectFSetAndGetLeft001
146  * @tc.desc:
147  * @tc.type: FUNC
148  * @tc.require:AR000GGNV3
149  * @tc.author:
150  */
151 HWTEST_F(RectTest, RectFSetAndGetLeft001, TestSize.Level1)
152 {
153     std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
154     rectF->SetLeft(1.0f);
155     EXPECT_EQ(1.0f, rectF->GetLeft());
156 }
157 
158 /**
159  * @tc.name: RectFSetAndGetLeft002
160  * @tc.desc:
161  * @tc.type: FUNC
162  * @tc.require:AR000GGNV3
163  * @tc.author:
164  */
165 HWTEST_F(RectTest, RectFSetAndGetLeft002, TestSize.Level1)
166 {
167     std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
168     rectF->SetLeft(2.0f);
169     EXPECT_EQ(2.0f, rectF->GetLeft());
170 }
171 
172 /**
173  * @tc.name: RectFSetAndGetRight001
174  * @tc.desc:
175  * @tc.type: FUNC
176  * @tc.require:AR000GGNV3
177  * @tc.author:
178  */
179 HWTEST_F(RectTest, RectFSetAndGetRight001, TestSize.Level1)
180 {
181     std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
182     rectF->SetRight(1.0f);
183     EXPECT_EQ(1.0f, rectF->GetRight());
184 }
185 
186 /**
187  * @tc.name: RectFSetAndGetRight002
188  * @tc.desc:
189  * @tc.type: FUNC
190  * @tc.require:AR000GGNV3
191  * @tc.author:
192  */
193 HWTEST_F(RectTest, RectFSetAndGetRight002, TestSize.Level1)
194 {
195     std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
196     rectF->SetRight(2.0f);
197     EXPECT_EQ(2.0f, rectF->GetRight());
198 }
199 
200 /**
201  * @tc.name: RectFSetAndGetTop001
202  * @tc.desc:
203  * @tc.type: FUNC
204  * @tc.require:AR000GGNV3
205  * @tc.author:
206  */
207 HWTEST_F(RectTest, RectFSetAndGetTop001, TestSize.Level1)
208 {
209     std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
210     rectF->SetTop(1.0f);
211     EXPECT_EQ(1.0f, rectF->GetTop());
212 }
213 
214 /**
215  * @tc.name: RectFSetAndGetTop002
216  * @tc.desc:
217  * @tc.type: FUNC
218  * @tc.require:AR000GGNV3
219  * @tc.author:
220  */
221 HWTEST_F(RectTest, RectFSetAndGetTop002, TestSize.Level1)
222 {
223     std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
224     rectF->SetTop(2.0f);
225     EXPECT_EQ(2.0f, rectF->GetTop());
226 }
227 
228 /**
229  * @tc.name: RectFSetAndGetBottom001
230  * @tc.desc:
231  * @tc.type: FUNC
232  * @tc.require:AR000GGNV3
233  * @tc.author:
234  */
235 HWTEST_F(RectTest, RectFSetAndGetBottom001, TestSize.Level1)
236 {
237     std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
238     rectF->SetBottom(1.0f);
239     EXPECT_EQ(1.0f, rectF->GetBottom());
240 }
241 
242 /**
243  * @tc.name: RectFSetAndGetBottom002
244  * @tc.desc:
245  * @tc.type: FUNC
246  * @tc.require:AR000GGNV3
247  * @tc.author:
248  */
249 HWTEST_F(RectTest, RectFSetAndGetBottom002, TestSize.Level1)
250 {
251     std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
252     rectF->SetBottom(2.0f);
253     EXPECT_EQ(2.0f, rectF->GetBottom());
254 }
255 
256 /**
257  * @tc.name: RectFOffset001
258  * @tc.desc:
259  * @tc.type: FUNC
260  * @tc.require:AR000GGNV3
261  * @tc.author:
262  */
263 HWTEST_F(RectTest, RectFOffset001, TestSize.Level1)
264 {
265     std::unique_ptr<RectF> rectF = std::make_unique<RectF>(1.0f, 2.0f, 3.0f, 4.0f);
266     rectF->Offset(1.0f, 2.0f);
267     EXPECT_EQ(2.0f, rectF->GetLeft());
268     EXPECT_EQ(4.0f, rectF->GetRight());
269     EXPECT_EQ(4.0f, rectF->GetTop());
270     EXPECT_EQ(6.0f, rectF->GetBottom());
271 }
272 
273 /**
274  * @tc.name: RectFOffset002
275  * @tc.desc:
276  * @tc.type: FUNC
277  * @tc.require:AR000GGNV3
278  * @tc.author:
279  */
280 HWTEST_F(RectTest, RectFOffset002, TestSize.Level1)
281 {
282     std::unique_ptr<RectF> rectF = std::make_unique<RectF>(1.0f, 2.0f, 3.0f, 4.0f);
283     rectF->Offset(2.0f, 1.0f);
284     EXPECT_EQ(3.0f, rectF->GetLeft());
285     EXPECT_EQ(5.0f, rectF->GetRight());
286     EXPECT_EQ(3.0f, rectF->GetTop());
287     EXPECT_EQ(5.0f, rectF->GetBottom());
288 }
289 
290 /**
291  * @tc.name: RectFMakeOutset001
292  * @tc.desc:
293  * @tc.type: FUNC
294  * @tc.require:AR000GGNV3
295  * @tc.author:
296  */
297 HWTEST_F(RectTest, RectFMakeOutset001, TestSize.Level1)
298 {
299     std::unique_ptr<RectF> rectF = std::make_unique<RectF>(1.0f, 2.0f, 3.0f, 4.0f);
300     rectF->MakeOutset(1.0f, 2.0f);
301     EXPECT_EQ(0.0f, rectF->GetLeft());
302     EXPECT_EQ(4.0f, rectF->GetRight());
303     EXPECT_EQ(0.0f, rectF->GetTop());
304     EXPECT_EQ(6.0f, rectF->GetBottom());
305 }
306 
307 /**
308  * @tc.name: RectFMakeOutset002
309  * @tc.desc:
310  * @tc.type: FUNC
311  * @tc.require:AR000GGNV3
312  * @tc.author:
313  */
314 HWTEST_F(RectTest, RectFMakeOutset002, TestSize.Level1)
315 {
316     std::unique_ptr<RectF> rectF = std::make_unique<RectF>(1.0f, 2.0f, 3.0f, 4.0f);
317     rectF->MakeOutset(2.0f, 1.0f);
318     EXPECT_EQ(-1.0f, rectF->GetLeft());
319     EXPECT_EQ(5.0f, rectF->GetRight());
320     EXPECT_EQ(1.0f, rectF->GetTop());
321     EXPECT_EQ(5.0f, rectF->GetBottom());
322 }
323 
324 
325 /**
326  * @tc.name: RectFEqual001
327  * @tc.desc:
328  * @tc.type: FUNC
329  * @tc.require:AR000GGNV3
330  * @tc.author:
331  */
332 HWTEST_F(RectTest, RectFEqual001, TestSize.Level1)
333 {
334     RectF rectf1;
335     RectF rectf2;
336     rectf1.SetLeft(1.0f);
337     EXPECT_FALSE(rectf1 == rectf2);
338 }
339 
340 /**
341  * @tc.name: RectFEqual002
342  * @tc.desc:
343  * @tc.type: FUNC
344  * @tc.require:AR000GGNV3
345  * @tc.author:
346  */
347 HWTEST_F(RectTest, RectFEqual002, TestSize.Level1)
348 {
349     RectF rectf1;
350     RectF rectf2;
351     EXPECT_TRUE(rectf1 == rectf2);
352 }
353 
354 /**
355  * @tc.name: RectFNotEqual001
356  * @tc.desc:
357  * @tc.type: FUNC
358  * @tc.require:AR000GGNV3
359  * @tc.author:
360  */
361 HWTEST_F(RectTest, RectFNotEqual001, TestSize.Level1)
362 {
363     RectF rectf1;
364     RectF rectf2;
365     EXPECT_FALSE(rectf1 != rectf2);
366 }
367 
368 /**
369  * @tc.name: RectFNotEqual002
370  * @tc.desc:
371  * @tc.type: FUNC
372  * @tc.require:AR000GGNV3
373  * @tc.author:
374  */
375 HWTEST_F(RectTest, RectFNotEqual002, TestSize.Level1)
376 {
377     RectF rectf1;
378     RectF rectf2;
379     rectf2.SetLeft(2.0f);
380     EXPECT_TRUE(rectf1 != rectf2);
381 }
382 
383 /**
384  * @tc.name: RectIntersect001
385  * @tc.desc: test for seting RectF to intersection.
386  * @tc.type: FUNC
387  * @tc.require: I6ZMMK
388  */
389 HWTEST_F(RectTest, RectIntersect001, TestSize.Level1)
390 {
391     RectF rectf1(1.0f, 2.0f, 3.0f, 4.0f);
392     RectF rectf2;
393     EXPECT_FALSE(rectf2.Intersect(rectf1));
394 }
395 
396 /**
397  * @tc.name: RectIntersect002
398  * @tc.desc: test for seting RectF to intersection.
399  * @tc.type: FUNC
400  * @tc.require: I6ZMMK
401  */
402 HWTEST_F(RectTest, RectIntersect002, TestSize.Level1)
403 {
404     RectF rectf1;
405     RectF rectf2;
406     EXPECT_FALSE(rectf2.Intersect(rectf1));
407 }
408 
409 /**
410  * @tc.name: RectIntersect003
411  * @tc.desc: test for seting RectF to intersection.
412  * @tc.type: FUNC
413  * @tc.require: I6ZMMK
414  */
415 HWTEST_F(RectTest, RectIntersect003, TestSize.Level1)
416 {
417     RectF rectf1(1.0f, 2.0f, 3.0f, 4.0f);
418     RectF rectf2(1.0f, 2.0f, 3.0f, 5.0f);
419     EXPECT_TRUE(rectf2.Intersect(rectf1));
420 }
421 
422 /**
423  * @tc.name: RectJoin001
424  * @tc.desc: test for seting RectF to the union of itself and other.
425  * @tc.type: FUNC
426  * @tc.require: I6ZMMK
427  */
428 HWTEST_F(RectTest, RectJoin001, TestSize.Level1)
429 {
430     RectF rectf1(1.0f, 2.0f, 3.0f, 4.0f);
431     RectF rectf2;
432     EXPECT_TRUE(rectf2.Join(rectf1));
433 }
434 
435 /**
436  * @tc.name: RectJoin002
437  * @tc.desc: test for seting RectF to the union of itself and other.
438  * @tc.type: FUNC
439  * @tc.require: I6ZMMK
440  */
441 HWTEST_F(RectTest, RectJoin002, TestSize.Level1)
442 {
443     RectF rectf1;
444     RectF rectf2;
445     EXPECT_FALSE(rectf2.Join(rectf1));
446 }
447 
448 /**
449  * @tc.name: RectJoin003
450  * @tc.desc: test for seting RectF to the union of itself and other.
451  * @tc.type: FUNC
452  * @tc.require: I6ZMMK
453  */
454 HWTEST_F(RectTest, RectJoin003, TestSize.Level1)
455 {
456     RectF rectf1(2.0f, 4.0f, 6.0f, 8.0f);
457     RectF rectf2(1.0f, 2.0f, 3.0f, 5.0f);
458     EXPECT_TRUE(rectf2.Join(rectf1));
459 }
460 
461 /**
462  * @tc.name: RectIsIntersect001
463  * @tc.desc: test for determine whether this and other intersect.
464  * @tc.type: FUNC
465  * @tc.require: IC2DF1
466  */
467 HWTEST_F(RectTest, RectIsIntersect001, TestSize.Level1)
468 {
469     RectF rectf1(0.0f, 0.0f, 100.0f, 100.0f);
470     RectF rectf2(30.0f, 30.0f, 70.0f, 70.0f);
471     EXPECT_TRUE(rectf1.IsIntersect(rectf2));
472 }
473 
474 /**
475  * @tc.name: RectIsIntersect002
476  * @tc.desc: test for determine whether this and other intersect.
477  * @tc.type: FUNC
478  * @tc.require: IC2DF1
479  */
480 HWTEST_F(RectTest, RectIsIntersect002, TestSize.Level1)
481 {
482     RectF rectf1(0.0f, 0.0f, 100.0f, 100.0f);
483     RectF rectf2(0.0f, 50.0f, 100.0f, 150.0f);
484     EXPECT_TRUE(rectf1.IsIntersect(rectf2));
485 }
486 
487 /**
488  * @tc.name: RectIsIntersect003
489  * @tc.desc: test for determine whether this and other intersect.
490  * @tc.type: FUNC
491  * @tc.require: IC2DF1
492  */
493 HWTEST_F(RectTest, RectIsIntersect003, TestSize.Level1)
494 {
495     RectF rectf1(0.0f, 0.0f, 100.0f, 100.0f);
496     RectF rectf2(0.0f, 100.0f, 100.0f, 200.0f);
497     EXPECT_FALSE(rectf1.IsIntersect(rectf2));
498 }
499 
500 /**
501  * @tc.name: RectContains001
502  * @tc.desc: test for determine if (x, y) is within this rectangle.
503  * @tc.type: FUNC
504  * @tc.require: IC2DF1
505  */
506 HWTEST_F(RectTest, RectContains001, TestSize.Level1)
507 {
508     RectF rectf(0.0f, 0.0f, 100.0f, 100.0f);
509     EXPECT_TRUE(rectf.Contains(50.0f, 50.0f));
510 }
511 
512 /**
513  * @tc.name: RectContains002
514  * @tc.desc: test for determine if (x, y) is within this rectangle.
515  * @tc.type: FUNC
516  * @tc.require: IC2DF1
517  */
518 HWTEST_F(RectTest, RectContains002, TestSize.Level1)
519 {
520     RectF rectf(0.0f, 0.0f, 100.0f, 100.0f);
521     EXPECT_TRUE(rectf.Contains(0.0f, 50.0f));
522 }
523 
524 /**
525  * @tc.name: RectContains003
526  * @tc.desc: test for determine if (x, y) is within this rectangle.
527  * @tc.type: FUNC
528  * @tc.require: IC2DF1
529  */
530 HWTEST_F(RectTest, RectContains003, TestSize.Level1)
531 {
532     RectF rectf(0.0f, 0.0f, 100.0f, 100.0f);
533     EXPECT_FALSE(rectf.Contains(100.0f, 50.0f));
534 }
535 
536 /**
537  * @tc.name: RectContains004
538  * @tc.desc: test for determine if (x, y) is within this rectangle.
539  * @tc.type: FUNC
540  * @tc.require: IC2DF1
541  */
542 HWTEST_F(RectTest, RectContains004, TestSize.Level1)
543 {
544     RectF rectf;
545     EXPECT_FALSE(rectf.Contains(0.0f, 0.0f));
546 }
547 
548 /**
549  * @tc.name: RectContains005
550  * @tc.desc: test for determine if other rectangle is inside this rectangle.
551  * @tc.type: FUNC
552  * @tc.require: IC2DF1
553  */
554 HWTEST_F(RectTest, RectContains005, TestSize.Level1)
555 {
556     RectF rectf1(0.0f, 0.0f, 100.0f, 100.0f);
557     RectF rectf2(30.0f, 30.0f, 70.0f, 70.0f);
558     EXPECT_TRUE(rectf1.Contains(rectf2));
559 }
560 
561 /**
562  * @tc.name: RectContains006
563  * @tc.desc: test for determine if other rectangle is inside this rectangle.
564  * @tc.type: FUNC
565  * @tc.require: IC2DF1
566  */
567 HWTEST_F(RectTest, RectContains006, TestSize.Level1)
568 {
569     RectF rectf1(0.0f, 0.0f, 100.0f, 100.0f);
570     RectF rectf2(50.0f, 50.0f, 150.0f, 150.0f);
571     EXPECT_FALSE(rectf1.Contains(rectf2));
572 }
573 
574 /**
575  * @tc.name: RectContains007
576  * @tc.desc: test for determine if other rectangle is inside this rectangle.
577  * @tc.type: FUNC
578  * @tc.require: IC2DF1
579  */
580 HWTEST_F(RectTest, RectContains007, TestSize.Level1)
581 {
582     RectF rectf1(0.0f, 0.0f, 100.0f, 100.0f);
583     RectF rectf2(0.0f, 0.0f, 100.0f, 50.0f);
584     EXPECT_TRUE(rectf1.Contains(rectf2));
585 }
586 
587 /**
588  * @tc.name: RectContains008
589  * @tc.desc: test for determine if other rectangle is inside this rectangle.
590  * @tc.type: FUNC
591  * @tc.require: IC2DF1
592  */
593 HWTEST_F(RectTest, RectContains008, TestSize.Level1)
594 {
595     RectF rectf1(0.0f, 0.0f, 100.0f, 100.0f);
596     RectF rectf2(0.0f, 0.0f, 100.0f, 150.0f);
597     EXPECT_FALSE(rectf1.Contains(rectf2));
598 }
599 
600 /**
601  * @tc.name: RectContains009
602  * @tc.desc: test for determine if other rectangle is inside this rectangle.
603  * @tc.type: FUNC
604  * @tc.require: IC2DF1
605  */
606 HWTEST_F(RectTest, RectContains009, TestSize.Level1)
607 {
608     RectF rectf1;
609     RectF rectf2(0.0f, 0.0f, 100.0f, 100.0f);
610     EXPECT_FALSE(rectf1.Contains(rectf2));
611 }
612 
613 /**
614  * @tc.name: RectContains010
615  * @tc.desc: test for determine if other rectangle is inside this rectangle.
616  * @tc.type: FUNC
617  * @tc.require: IC2DF1
618  */
619 HWTEST_F(RectTest, RectContains010, TestSize.Level1)
620 {
621     RectF rectf1(0.0f, 0.0f, 100.0f, 100.0f);
622     RectF rectf2;
623     EXPECT_FALSE(rectf1.Contains(rectf2));
624 }
625 
626 /**
627  * @tc.name: RectContains011
628  * @tc.desc: test for determine if other rectangle is inside this rectangle.
629  * @tc.type: FUNC
630  * @tc.require: IC2DF1
631  */
632 HWTEST_F(RectTest, RectContains011, TestSize.Level1)
633 {
634     RectF rectf(0.0f, 0.0f, 100.0f, 100.0f);
635     EXPECT_TRUE(rectf.Contains(rectf));
636 }
637 
638 /**
639  * @tc.name: RectContains012
640  * @tc.desc: test for determine if other rectangle is inside this rectangle.
641  * @tc.type: FUNC
642  * @tc.require: IC2DF1
643  */
644 HWTEST_F(RectTest, RectContains012, TestSize.Level1)
645 {
646     RectF rectf1(0.0f, 0.0f, 100.0f, 100.0f);
647     RectF rectf2(100.0f, 100.0f, 0.0f, 0.0f);
648     EXPECT_FALSE(rectf1.Contains(rectf2));
649 }
650 
651 /**
652  * @tc.name: RectContains013
653  * @tc.desc: test for determine if other rectangle is inside this rectangle.
654  * @tc.type: FUNC
655  * @tc.require: IC2DF1
656  */
657 HWTEST_F(RectTest, RectContains013, TestSize.Level1)
658 {
659     RectF rectf1(100.0f, 100.0f, 0.0f, 0.0f);
660     RectF rectf2(0.0f, 0.0f, 100.0f, 100.0f);
661     EXPECT_FALSE(rectf1.Contains(rectf2));
662 }
663 
664 /**
665  * @tc.name: RectSort001
666  * @tc.desc: test for swap the left and right sides of the swap rectangle.
667  * @tc.type: FUNC
668  * @tc.require: IC2DF1
669  */
670 HWTEST_F(RectTest, RectSort001, TestSize.Level1)
671 {
672     RectF rectf(0.0f, 0.0f, 100.0f, 100.0f);
673     rectf.Sort();
674     EXPECT_EQ(0.0f, rectf.GetLeft());
675     EXPECT_EQ(0.0f, rectf.GetTop());
676     EXPECT_EQ(100.0f, rectf.GetRight());
677     EXPECT_EQ(100.0f, rectf.GetBottom());
678 }
679 
680 /**
681  * @tc.name: RectSort002
682  * @tc.desc: test for swap the left and right sides of the swap rectangle.
683  * @tc.type: FUNC
684  * @tc.require: IC2DF1
685  */
686 HWTEST_F(RectTest, RectSort002, TestSize.Level1)
687 {
688     RectF rectf(100.0f, 100.0f, 0.0f, 0.0f);
689     rectf.Sort();
690     EXPECT_EQ(0.0f, rectf.GetLeft());
691     EXPECT_EQ(0.0f, rectf.GetTop());
692     EXPECT_EQ(100.0f, rectf.GetRight());
693     EXPECT_EQ(100.0f, rectf.GetBottom());
694 }
695 
696 /**
697  * @tc.name: RectICreateAndDestroy001
698  * @tc.desc:
699  * @tc.type: FUNC
700  * @tc.require:AR000GGNV3
701  * @tc.author:
702  */
703 HWTEST_F(RectTest, RectICreateAndDestroy001, TestSize.Level1)
704 {
705     std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
706     EXPECT_EQ(0.0f, rectI->GetLeft());
707     EXPECT_EQ(0.0f, rectI->GetTop());
708     EXPECT_EQ(0.0f, rectI->GetRight());
709     EXPECT_EQ(0.0f, rectI->GetBottom());
710 }
711 
712 /**
713  * @tc.name: RectICreateAndDestroy002
714  * @tc.desc:
715  * @tc.type: FUNC
716  * @tc.require:AR000GGNV3
717  * @tc.author:
718  */
719 HWTEST_F(RectTest, RectICreateAndDestroy002, TestSize.Level1)
720 {
721     RectI recti1;
722     recti1.SetLeft(1.0f);
723     RectI recti2(recti1);
724     EXPECT_EQ(recti1.GetLeft(), recti2.GetLeft());
725 }
726 
727 /**
728  * @tc.name: RectICreateAndDestroy003
729  * @tc.desc:
730  * @tc.type: FUNC
731  * @tc.require:AR000GGNV3
732  * @tc.author:
733  */
734 HWTEST_F(RectTest, RectICreateAndDestroy003, TestSize.Level1)
735 {
736     RectI recti1;
737     recti1.SetLeft(2.0f);
738     RectI recti2(recti1);
739     EXPECT_EQ(recti1.GetLeft(), recti2.GetLeft());
740 }
741 
742 /**
743  * @tc.name: RectICreateAndDestroy004
744  * @tc.desc:
745  * @tc.type: FUNC
746  * @tc.require:AR000GGNV3
747  * @tc.author:
748  */
749 HWTEST_F(RectTest, RectICreateAndDestroy004, TestSize.Level1)
750 {
751     std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
752     EXPECT_EQ(1.0f, rectI->GetLeft());
753     EXPECT_EQ(2.0f, rectI->GetTop());
754     EXPECT_EQ(3.0f, rectI->GetRight());
755     EXPECT_EQ(4.0f, rectI->GetBottom());
756 }
757 
758 /**
759  * @tc.name: RectICreateAndDestroy005
760  * @tc.desc:
761  * @tc.type: FUNC
762  * @tc.require:AR000GGNV3
763  * @tc.author:
764  */
765 HWTEST_F(RectTest, RectICreateAndDestroy005, TestSize.Level1)
766 {
767     std::unique_ptr<RectI> rectI = std::make_unique<RectI>(4.0f, 3.0f, 2.0f, 1.0f);
768     EXPECT_EQ(4.0f, rectI->GetLeft());
769     EXPECT_EQ(3.0f, rectI->GetTop());
770     EXPECT_EQ(2.0f, rectI->GetRight());
771     EXPECT_EQ(1.0f, rectI->GetBottom());
772 }
773 
774 /**
775  * @tc.name: RectIIsValid001
776  * @tc.desc:
777  * @tc.type: FUNC
778  * @tc.require:AR000GGNV3
779  * @tc.author:
780  */
781 HWTEST_F(RectTest, RectIIsValid001, TestSize.Level1)
782 {
783     std::unique_ptr<RectI> rectI = std::make_unique<RectI>(4.0f, 3.0f, 2.0f, 1.0f);
784     EXPECT_FALSE(rectI->IsValid());
785 }
786 
787 /**
788  * @tc.name: RectIIsValid002
789  * @tc.desc:
790  * @tc.type: FUNC
791  * @tc.require:AR000GGNV3
792  * @tc.author:
793  */
794 HWTEST_F(RectTest, RectIIsValid002, TestSize.Level1)
795 {
796     std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
797     EXPECT_TRUE(rectI->IsValid());
798 }
799 
800 /**
801  * @tc.name: RectISetAndGetLeft001
802  * @tc.desc:
803  * @tc.type: FUNC
804  * @tc.require:AR000GGNV3
805  * @tc.author:
806  */
807 HWTEST_F(RectTest, RectISetAndGetLeft001, TestSize.Level1)
808 {
809     std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
810     rectI->SetLeft(1.0f);
811     EXPECT_EQ(1.0f, rectI->GetLeft());
812 }
813 
814 /**
815  * @tc.name: RectISetAndGetLeft002
816  * @tc.desc:
817  * @tc.type: FUNC
818  * @tc.require:AR000GGNV3
819  * @tc.author:
820  */
821 HWTEST_F(RectTest, RectISetAndGetLeft002, TestSize.Level1)
822 {
823     std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
824     rectI->SetLeft(2.0f);
825     EXPECT_EQ(2.0f, rectI->GetLeft());
826 }
827 
828 /**
829  * @tc.name: RectISetAndGetRight001
830  * @tc.desc:
831  * @tc.type: FUNC
832  * @tc.require:AR000GGNV3
833  * @tc.author:
834  */
835 HWTEST_F(RectTest, RectISetAndGetRight001, TestSize.Level1)
836 {
837     std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
838     rectI->SetRight(1.0f);
839     EXPECT_EQ(1.0f, rectI->GetRight());
840 }
841 
842 /**
843  * @tc.name: RectISetAndGetRight002
844  * @tc.desc:
845  * @tc.type: FUNC
846  * @tc.require:AR000GGNV3
847  * @tc.author:
848  */
849 HWTEST_F(RectTest, RectISetAndGetRight002, TestSize.Level1)
850 {
851     std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
852     rectI->SetRight(2.0f);
853     EXPECT_EQ(2.0f, rectI->GetRight());
854 }
855 
856 /**
857  * @tc.name: RectISetAndGetTop001
858  * @tc.desc:
859  * @tc.type: FUNC
860  * @tc.require:AR000GGNV3
861  * @tc.author:
862  */
863 HWTEST_F(RectTest, RectISetAndGetTop001, TestSize.Level1)
864 {
865     std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
866     rectI->SetTop(1.0f);
867     EXPECT_EQ(1.0f, rectI->GetTop());
868 }
869 
870 /**
871  * @tc.name: RectISetAndGetTop002
872  * @tc.desc:
873  * @tc.type: FUNC
874  * @tc.require:AR000GGNV3
875  * @tc.author:
876  */
877 HWTEST_F(RectTest, RectISetAndGetTop002, TestSize.Level1)
878 {
879     std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
880     rectI->SetTop(2.0f);
881     EXPECT_EQ(2.0f, rectI->GetTop());
882 }
883 
884 /**
885  * @tc.name: RectISetAndGetBottom001
886  * @tc.desc:
887  * @tc.type: FUNC
888  * @tc.require:AR000GGNV3
889  * @tc.author:
890  */
891 HWTEST_F(RectTest, RectISetAndGetBottom001, TestSize.Level1)
892 {
893     std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
894     rectI->SetBottom(1.0f);
895     EXPECT_EQ(1.0f, rectI->GetBottom());
896 }
897 
898 /**
899  * @tc.name: RectISetAndGetBottom002
900  * @tc.desc:
901  * @tc.type: FUNC
902  * @tc.require:AR000GGNV3
903  * @tc.author:
904  */
905 HWTEST_F(RectTest, RectISetAndGetBottom002, TestSize.Level1)
906 {
907     std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
908     rectI->SetBottom(2.0f);
909     EXPECT_EQ(2.0f, rectI->GetBottom());
910 }
911 
912 /**
913  * @tc.name: RectIOffset001
914  * @tc.desc:
915  * @tc.type: FUNC
916  * @tc.require:AR000GGNV3
917  * @tc.author:
918  */
919 HWTEST_F(RectTest, RectIOffset001, TestSize.Level1)
920 {
921     std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
922     rectI->Offset(1.0f, 2.0f);
923     EXPECT_EQ(2.0f, rectI->GetLeft());
924     EXPECT_EQ(4.0f, rectI->GetRight());
925     EXPECT_EQ(4.0f, rectI->GetTop());
926     EXPECT_EQ(6.0f, rectI->GetBottom());
927 }
928 
929 /**
930  * @tc.name: RectIOffset002
931  * @tc.desc:
932  * @tc.type: FUNC
933  * @tc.require:AR000GGNV3
934  * @tc.author:
935  */
936 HWTEST_F(RectTest, RectIOffset002, TestSize.Level1)
937 {
938     std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
939     rectI->Offset(2.0f, 1.0f);
940     EXPECT_EQ(3.0f, rectI->GetLeft());
941     EXPECT_EQ(5.0f, rectI->GetRight());
942     EXPECT_EQ(3.0f, rectI->GetTop());
943     EXPECT_EQ(5.0f, rectI->GetBottom());
944 }
945 
946 /**
947  * @tc.name: RectIMakeOutset001
948  * @tc.desc:
949  * @tc.type: FUNC
950  * @tc.require:AR000GGNV3
951  * @tc.author:
952  */
953 HWTEST_F(RectTest, RectIMakeOutset001, TestSize.Level1)
954 {
955     std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
956     rectI->MakeOutset(1.0f, 2.0f);
957     EXPECT_EQ(0.0f, rectI->GetLeft());
958     EXPECT_EQ(4.0f, rectI->GetRight());
959     EXPECT_EQ(0.0f, rectI->GetTop());
960     EXPECT_EQ(6.0f, rectI->GetBottom());
961 }
962 
963 /**
964  * @tc.name: RectIMakeOutset002
965  * @tc.desc:
966  * @tc.type: FUNC
967  * @tc.require:AR000GGNV3
968  * @tc.author:
969  */
970 HWTEST_F(RectTest, RectIMakeOutset002, TestSize.Level1)
971 {
972     std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
973     rectI->MakeOutset(2.0f, 1.0f);
974     EXPECT_EQ(-1.0f, rectI->GetLeft());
975     EXPECT_EQ(5.0f, rectI->GetRight());
976     EXPECT_EQ(1.0f, rectI->GetTop());
977     EXPECT_EQ(5.0f, rectI->GetBottom());
978 }
979 
980 /**
981  * @tc.name: RectIEqual001
982  * @tc.desc:
983  * @tc.type: FUNC
984  * @tc.require:AR000GGNV3
985  * @tc.author:
986  */
987 HWTEST_F(RectTest, RectIEqual001, TestSize.Level1)
988 {
989     RectI recti1;
990     RectI recti2;
991     recti1.SetLeft(1.0f);
992     EXPECT_FALSE(recti1 == recti2);
993 }
994 
995 /**
996  * @tc.name: RectIEqual002
997  * @tc.desc:
998  * @tc.type: FUNC
999  * @tc.require:AR000GGNV3
1000  * @tc.author:
1001  */
1002 HWTEST_F(RectTest, RectIEqual002, TestSize.Level1)
1003 {
1004     RectI recti1;
1005     RectI recti2;
1006     EXPECT_TRUE(recti1 == recti2);
1007 }
1008 
1009 /**
1010  * @tc.name: RectINotEqual001
1011  * @tc.desc:
1012  * @tc.type: FUNC
1013  * @tc.require:AR000GGNV3
1014  * @tc.author:
1015  */
1016 HWTEST_F(RectTest, RectINotEqual001, TestSize.Level1)
1017 {
1018     RectI recti1;
1019     RectI recti2;
1020     EXPECT_FALSE(recti1 != recti2);
1021 }
1022 
1023 /**
1024  * @tc.name: RectINotEqual002
1025  * @tc.desc:
1026  * @tc.type: FUNC
1027  * @tc.require:AR000GGNV3
1028  * @tc.author:
1029  */
1030 HWTEST_F(RectTest, RectINotEqual002, TestSize.Level1)
1031 {
1032     RectI recti1;
1033     RectI recti2;
1034     recti2.SetLeft(2.0f);
1035     EXPECT_TRUE(recti1 != recti2);
1036 }
1037 
1038 /**
1039  * @tc.name: RectIIntersect001
1040  * @tc.desc: test for seting RectI to intersection.
1041  * @tc.type: FUNC
1042  * @tc.require: I6ZMMK
1043  */
1044 HWTEST_F(RectTest, RectIIntersect001, TestSize.Level1)
1045 {
1046     RectI rectI1(1, 2, 3, 4);
1047     RectI rectI2;
1048     EXPECT_FALSE(rectI2.Intersect(rectI1));
1049 }
1050 
1051 /**
1052  * @tc.name: RectIIntersect002
1053  * @tc.desc: test for seting RectI to intersection.
1054  * @tc.type: FUNC
1055  * @tc.require: I6ZMMK
1056  */
1057 HWTEST_F(RectTest, RectIIntersect002, TestSize.Level1)
1058 {
1059     RectI rectI1;
1060     RectI rectI2;
1061     EXPECT_FALSE(rectI2.Intersect(rectI1));
1062 }
1063 
1064 /**
1065  * @tc.name: RectIIntersect003
1066  * @tc.desc: test for seting RectI to intersection.
1067  * @tc.type: FUNC
1068  * @tc.require: I6ZMMK
1069  */
1070 HWTEST_F(RectTest, RectIIntersect003, TestSize.Level1)
1071 {
1072     RectI rectI1(1, 2, 3, 4);
1073     RectI rectI2(1, 2, 3, 5);
1074     EXPECT_TRUE(rectI2.Intersect(rectI1));
1075 }
1076 
1077 /**
1078  * @tc.name: RectIJoin001
1079  * @tc.desc: test for seting RectI to the union of itself and other.
1080  * @tc.type: FUNC
1081  * @tc.require: I6ZMMK
1082  */
1083 HWTEST_F(RectTest, RectIJoin001, TestSize.Level1)
1084 {
1085     RectI rectI1(1, 2, 3, 4);
1086     RectI rectI2;
1087     EXPECT_TRUE(rectI2.Join(rectI1));
1088 }
1089 
1090 /**
1091  * @tc.name: RectIJoin002
1092  * @tc.desc: test for seting RectI to the union of itself and other.
1093  * @tc.type: FUNC
1094  * @tc.require: I6ZMMK
1095  */
1096 HWTEST_F(RectTest, RectIJoin002, TestSize.Level1)
1097 {
1098     RectI rectI1;
1099     RectI rectI2;
1100     EXPECT_FALSE(rectI2.Join(rectI1));
1101 }
1102 
1103 /**
1104  * @tc.name: RectIJoin003
1105  * @tc.desc: test for seting RectI to the union of itself and other.
1106  * @tc.type: FUNC
1107  * @tc.require: I6ZMMK
1108  */
1109 HWTEST_F(RectTest, RectIJoin003, TestSize.Level1)
1110 {
1111     RectI rectI1(2, 4, 6, 8);
1112     RectI rectI2(1, 2, 3, 5);
1113     EXPECT_TRUE(rectI2.Join(rectI1));
1114     EXPECT_EQ(rectI2.GetLeft(), 1);
1115     EXPECT_EQ(rectI2.GetBottom(), 8);
1116 }
1117 } // namespace Drawing
1118 } // namespace Rosen
1119 } // namespace OHOS