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: RectICreateAndDestroy001
463 * @tc.desc:
464 * @tc.type: FUNC
465 * @tc.require:AR000GGNV3
466 * @tc.author:
467 */
468 HWTEST_F(RectTest, RectICreateAndDestroy001, TestSize.Level1)
469 {
470 std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
471 EXPECT_EQ(0.0f, rectI->GetLeft());
472 EXPECT_EQ(0.0f, rectI->GetTop());
473 EXPECT_EQ(0.0f, rectI->GetRight());
474 EXPECT_EQ(0.0f, rectI->GetBottom());
475 }
476
477 /**
478 * @tc.name: RectICreateAndDestroy002
479 * @tc.desc:
480 * @tc.type: FUNC
481 * @tc.require:AR000GGNV3
482 * @tc.author:
483 */
484 HWTEST_F(RectTest, RectICreateAndDestroy002, TestSize.Level1)
485 {
486 RectI recti1;
487 recti1.SetLeft(1.0f);
488 RectI recti2(recti1);
489 EXPECT_EQ(recti1.GetLeft(), recti2.GetLeft());
490 }
491
492 /**
493 * @tc.name: RectICreateAndDestroy003
494 * @tc.desc:
495 * @tc.type: FUNC
496 * @tc.require:AR000GGNV3
497 * @tc.author:
498 */
499 HWTEST_F(RectTest, RectICreateAndDestroy003, TestSize.Level1)
500 {
501 RectI recti1;
502 recti1.SetLeft(2.0f);
503 RectI recti2(recti1);
504 EXPECT_EQ(recti1.GetLeft(), recti2.GetLeft());
505 }
506
507 /**
508 * @tc.name: RectICreateAndDestroy004
509 * @tc.desc:
510 * @tc.type: FUNC
511 * @tc.require:AR000GGNV3
512 * @tc.author:
513 */
514 HWTEST_F(RectTest, RectICreateAndDestroy004, TestSize.Level1)
515 {
516 std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
517 EXPECT_EQ(1.0f, rectI->GetLeft());
518 EXPECT_EQ(2.0f, rectI->GetTop());
519 EXPECT_EQ(3.0f, rectI->GetRight());
520 EXPECT_EQ(4.0f, rectI->GetBottom());
521 }
522
523 /**
524 * @tc.name: RectICreateAndDestroy005
525 * @tc.desc:
526 * @tc.type: FUNC
527 * @tc.require:AR000GGNV3
528 * @tc.author:
529 */
530 HWTEST_F(RectTest, RectICreateAndDestroy005, TestSize.Level1)
531 {
532 std::unique_ptr<RectI> rectI = std::make_unique<RectI>(4.0f, 3.0f, 2.0f, 1.0f);
533 EXPECT_EQ(4.0f, rectI->GetLeft());
534 EXPECT_EQ(3.0f, rectI->GetTop());
535 EXPECT_EQ(2.0f, rectI->GetRight());
536 EXPECT_EQ(1.0f, rectI->GetBottom());
537 }
538
539 /**
540 * @tc.name: RectIIsValid001
541 * @tc.desc:
542 * @tc.type: FUNC
543 * @tc.require:AR000GGNV3
544 * @tc.author:
545 */
546 HWTEST_F(RectTest, RectIIsValid001, TestSize.Level1)
547 {
548 std::unique_ptr<RectI> rectI = std::make_unique<RectI>(4.0f, 3.0f, 2.0f, 1.0f);
549 EXPECT_FALSE(rectI->IsValid());
550 }
551
552 /**
553 * @tc.name: RectIIsValid002
554 * @tc.desc:
555 * @tc.type: FUNC
556 * @tc.require:AR000GGNV3
557 * @tc.author:
558 */
559 HWTEST_F(RectTest, RectIIsValid002, TestSize.Level1)
560 {
561 std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
562 EXPECT_TRUE(rectI->IsValid());
563 }
564
565 /**
566 * @tc.name: RectISetAndGetLeft001
567 * @tc.desc:
568 * @tc.type: FUNC
569 * @tc.require:AR000GGNV3
570 * @tc.author:
571 */
572 HWTEST_F(RectTest, RectISetAndGetLeft001, TestSize.Level1)
573 {
574 std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
575 rectI->SetLeft(1.0f);
576 EXPECT_EQ(1.0f, rectI->GetLeft());
577 }
578
579 /**
580 * @tc.name: RectISetAndGetLeft002
581 * @tc.desc:
582 * @tc.type: FUNC
583 * @tc.require:AR000GGNV3
584 * @tc.author:
585 */
586 HWTEST_F(RectTest, RectISetAndGetLeft002, TestSize.Level1)
587 {
588 std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
589 rectI->SetLeft(2.0f);
590 EXPECT_EQ(2.0f, rectI->GetLeft());
591 }
592
593 /**
594 * @tc.name: RectISetAndGetRight001
595 * @tc.desc:
596 * @tc.type: FUNC
597 * @tc.require:AR000GGNV3
598 * @tc.author:
599 */
600 HWTEST_F(RectTest, RectISetAndGetRight001, TestSize.Level1)
601 {
602 std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
603 rectI->SetRight(1.0f);
604 EXPECT_EQ(1.0f, rectI->GetRight());
605 }
606
607 /**
608 * @tc.name: RectISetAndGetRight002
609 * @tc.desc:
610 * @tc.type: FUNC
611 * @tc.require:AR000GGNV3
612 * @tc.author:
613 */
614 HWTEST_F(RectTest, RectISetAndGetRight002, TestSize.Level1)
615 {
616 std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
617 rectI->SetRight(2.0f);
618 EXPECT_EQ(2.0f, rectI->GetRight());
619 }
620
621 /**
622 * @tc.name: RectISetAndGetTop001
623 * @tc.desc:
624 * @tc.type: FUNC
625 * @tc.require:AR000GGNV3
626 * @tc.author:
627 */
628 HWTEST_F(RectTest, RectISetAndGetTop001, TestSize.Level1)
629 {
630 std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
631 rectI->SetTop(1.0f);
632 EXPECT_EQ(1.0f, rectI->GetTop());
633 }
634
635 /**
636 * @tc.name: RectISetAndGetTop002
637 * @tc.desc:
638 * @tc.type: FUNC
639 * @tc.require:AR000GGNV3
640 * @tc.author:
641 */
642 HWTEST_F(RectTest, RectISetAndGetTop002, TestSize.Level1)
643 {
644 std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
645 rectI->SetTop(2.0f);
646 EXPECT_EQ(2.0f, rectI->GetTop());
647 }
648
649 /**
650 * @tc.name: RectISetAndGetBottom001
651 * @tc.desc:
652 * @tc.type: FUNC
653 * @tc.require:AR000GGNV3
654 * @tc.author:
655 */
656 HWTEST_F(RectTest, RectISetAndGetBottom001, TestSize.Level1)
657 {
658 std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
659 rectI->SetBottom(1.0f);
660 EXPECT_EQ(1.0f, rectI->GetBottom());
661 }
662
663 /**
664 * @tc.name: RectISetAndGetBottom002
665 * @tc.desc:
666 * @tc.type: FUNC
667 * @tc.require:AR000GGNV3
668 * @tc.author:
669 */
670 HWTEST_F(RectTest, RectISetAndGetBottom002, TestSize.Level1)
671 {
672 std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
673 rectI->SetBottom(2.0f);
674 EXPECT_EQ(2.0f, rectI->GetBottom());
675 }
676
677 /**
678 * @tc.name: RectIOffset001
679 * @tc.desc:
680 * @tc.type: FUNC
681 * @tc.require:AR000GGNV3
682 * @tc.author:
683 */
684 HWTEST_F(RectTest, RectIOffset001, TestSize.Level1)
685 {
686 std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
687 rectI->Offset(1.0f, 2.0f);
688 EXPECT_EQ(2.0f, rectI->GetLeft());
689 EXPECT_EQ(4.0f, rectI->GetRight());
690 EXPECT_EQ(4.0f, rectI->GetTop());
691 EXPECT_EQ(6.0f, rectI->GetBottom());
692 }
693
694 /**
695 * @tc.name: RectIOffset002
696 * @tc.desc:
697 * @tc.type: FUNC
698 * @tc.require:AR000GGNV3
699 * @tc.author:
700 */
701 HWTEST_F(RectTest, RectIOffset002, TestSize.Level1)
702 {
703 std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
704 rectI->Offset(2.0f, 1.0f);
705 EXPECT_EQ(3.0f, rectI->GetLeft());
706 EXPECT_EQ(5.0f, rectI->GetRight());
707 EXPECT_EQ(3.0f, rectI->GetTop());
708 EXPECT_EQ(5.0f, rectI->GetBottom());
709 }
710
711 /**
712 * @tc.name: RectIMakeOutset001
713 * @tc.desc:
714 * @tc.type: FUNC
715 * @tc.require:AR000GGNV3
716 * @tc.author:
717 */
718 HWTEST_F(RectTest, RectIMakeOutset001, TestSize.Level1)
719 {
720 std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
721 rectI->MakeOutset(1.0f, 2.0f);
722 EXPECT_EQ(0.0f, rectI->GetLeft());
723 EXPECT_EQ(4.0f, rectI->GetRight());
724 EXPECT_EQ(0.0f, rectI->GetTop());
725 EXPECT_EQ(6.0f, rectI->GetBottom());
726 }
727
728 /**
729 * @tc.name: RectIMakeOutset002
730 * @tc.desc:
731 * @tc.type: FUNC
732 * @tc.require:AR000GGNV3
733 * @tc.author:
734 */
735 HWTEST_F(RectTest, RectIMakeOutset002, TestSize.Level1)
736 {
737 std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
738 rectI->MakeOutset(2.0f, 1.0f);
739 EXPECT_EQ(-1.0f, rectI->GetLeft());
740 EXPECT_EQ(5.0f, rectI->GetRight());
741 EXPECT_EQ(1.0f, rectI->GetTop());
742 EXPECT_EQ(5.0f, rectI->GetBottom());
743 }
744
745 /**
746 * @tc.name: RectIEqual001
747 * @tc.desc:
748 * @tc.type: FUNC
749 * @tc.require:AR000GGNV3
750 * @tc.author:
751 */
752 HWTEST_F(RectTest, RectIEqual001, TestSize.Level1)
753 {
754 RectI recti1;
755 RectI recti2;
756 recti1.SetLeft(1.0f);
757 EXPECT_FALSE(recti1 == recti2);
758 }
759
760 /**
761 * @tc.name: RectIEqual002
762 * @tc.desc:
763 * @tc.type: FUNC
764 * @tc.require:AR000GGNV3
765 * @tc.author:
766 */
767 HWTEST_F(RectTest, RectIEqual002, TestSize.Level1)
768 {
769 RectI recti1;
770 RectI recti2;
771 EXPECT_TRUE(recti1 == recti2);
772 }
773
774 /**
775 * @tc.name: RectINotEqual001
776 * @tc.desc:
777 * @tc.type: FUNC
778 * @tc.require:AR000GGNV3
779 * @tc.author:
780 */
781 HWTEST_F(RectTest, RectINotEqual001, TestSize.Level1)
782 {
783 RectI recti1;
784 RectI recti2;
785 EXPECT_FALSE(recti1 != recti2);
786 }
787
788 /**
789 * @tc.name: RectINotEqual002
790 * @tc.desc:
791 * @tc.type: FUNC
792 * @tc.require:AR000GGNV3
793 * @tc.author:
794 */
795 HWTEST_F(RectTest, RectINotEqual002, TestSize.Level1)
796 {
797 RectI recti1;
798 RectI recti2;
799 recti2.SetLeft(2.0f);
800 EXPECT_TRUE(recti1 != recti2);
801 }
802
803 /**
804 * @tc.name: RectIIntersect001
805 * @tc.desc: test for seting RectI to intersection.
806 * @tc.type: FUNC
807 * @tc.require: I6ZMMK
808 */
809 HWTEST_F(RectTest, RectIIntersect001, TestSize.Level1)
810 {
811 RectI rectI1(1, 2, 3, 4);
812 RectI rectI2;
813 EXPECT_FALSE(rectI2.Intersect(rectI1));
814 }
815
816 /**
817 * @tc.name: RectIIntersect002
818 * @tc.desc: test for seting RectI to intersection.
819 * @tc.type: FUNC
820 * @tc.require: I6ZMMK
821 */
822 HWTEST_F(RectTest, RectIIntersect002, TestSize.Level1)
823 {
824 RectI rectI1;
825 RectI rectI2;
826 EXPECT_FALSE(rectI2.Intersect(rectI1));
827 }
828
829 /**
830 * @tc.name: RectIIntersect003
831 * @tc.desc: test for seting RectI to intersection.
832 * @tc.type: FUNC
833 * @tc.require: I6ZMMK
834 */
835 HWTEST_F(RectTest, RectIIntersect003, TestSize.Level1)
836 {
837 RectI rectI1(1, 2, 3, 4);
838 RectI rectI2(1, 2, 3, 5);
839 EXPECT_TRUE(rectI2.Intersect(rectI1));
840 }
841
842 /**
843 * @tc.name: RectIJoin001
844 * @tc.desc: test for seting RectI to the union of itself and other.
845 * @tc.type: FUNC
846 * @tc.require: I6ZMMK
847 */
848 HWTEST_F(RectTest, RectIJoin001, TestSize.Level1)
849 {
850 RectI rectI1(1, 2, 3, 4);
851 RectI rectI2;
852 EXPECT_TRUE(rectI2.Join(rectI1));
853 }
854
855 /**
856 * @tc.name: RectIJoin002
857 * @tc.desc: test for seting RectI to the union of itself and other.
858 * @tc.type: FUNC
859 * @tc.require: I6ZMMK
860 */
861 HWTEST_F(RectTest, RectIJoin002, TestSize.Level1)
862 {
863 RectI rectI1;
864 RectI rectI2;
865 EXPECT_FALSE(rectI2.Join(rectI1));
866 }
867
868 /**
869 * @tc.name: RectIJoin003
870 * @tc.desc: test for seting RectI to the union of itself and other.
871 * @tc.type: FUNC
872 * @tc.require: I6ZMMK
873 */
874 HWTEST_F(RectTest, RectIJoin003, TestSize.Level1)
875 {
876 RectI rectI1(2, 4, 6, 8);
877 RectI rectI2(1, 2, 3, 5);
878 EXPECT_TRUE(rectI2.Join(rectI1));
879 EXPECT_EQ(rectI2.GetLeft(), 1);
880 EXPECT_EQ(rectI2.GetBottom(), 8);
881 }
882 } // namespace Drawing
883 } // namespace Rosen
884 } // namespace OHOS