• 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, software
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 <cstddef>
17 #include "gtest/gtest.h"
18 #include "skia_adapter/skia_region.h"
19 #include "utils/region.h"
20 #include "utils/rect.h"
21 
22 using namespace testing;
23 using namespace testing::ext;
24 
25 namespace OHOS {
26 namespace Rosen {
27 namespace Drawing {
28 class SkiaRegionTest : public testing::Test {
29 public:
30     static void SetUpTestCase();
31     static void TearDownTestCase();
32     void SetUp() override;
33     void TearDown() override;
34 };
35 
SetUpTestCase()36 void SkiaRegionTest::SetUpTestCase() {}
TearDownTestCase()37 void SkiaRegionTest::TearDownTestCase() {}
SetUp()38 void SkiaRegionTest::SetUp() {}
TearDown()39 void SkiaRegionTest::TearDown() {}
40 
41 /**
42  * @tc.name: SetPath001
43  * @tc.desc: Test SetPath
44  * @tc.type: FUNC
45  * @tc.require: I8VQSW
46  */
47 HWTEST_F(SkiaRegionTest, SetPath001, TestSize.Level1)
48 {
49     std::shared_ptr<SkiaRegion> skiaRegion = std::make_shared<SkiaRegion>();
50     Path path;
51     Region region;
52     skiaRegion->SetPath(path, region);
53 }
54 
55 /**
56  * @tc.name: GetBoundaryPath001
57  * @tc.desc: Test GetBoundaryPath
58  * @tc.type: FUNC
59  * @tc.require: I8VQSW
60  */
61 HWTEST_F(SkiaRegionTest, GetBoundaryPath001, TestSize.Level1)
62 {
63     std::shared_ptr<SkiaRegion> skiaRegion = std::make_shared<SkiaRegion>();
64     Path path;
65     skiaRegion->GetBoundaryPath(&path);
66     skiaRegion->GetBoundaryPath(nullptr);
67 }
68 
69 /**
70  * @tc.name: IsIntersects001
71  * @tc.desc: Test IsIntersects
72  * @tc.type: FUNC
73  * @tc.require: I8VQSW
74  */
75 HWTEST_F(SkiaRegionTest, IsIntersects001, TestSize.Level1)
76 {
77     std::shared_ptr<SkiaRegion> skiaRegion = std::make_shared<SkiaRegion>();
78     Region region;
79     auto ret = skiaRegion->IsIntersects(region);
80     EXPECT_TRUE(!ret);
81 }
82 
83 /**
84  * @tc.name: Clone001
85  * @tc.desc: Test Clone
86  * @tc.type: FUNC
87  * @tc.require: I8VQSW
88  */
89 HWTEST_F(SkiaRegionTest, Clone001, TestSize.Level1)
90 {
91     std::shared_ptr<SkiaRegion> skiaRegion = std::make_shared<SkiaRegion>();
92     Region region;
93     skiaRegion->Clone(region);
94 }
95 
96 /**
97  * @tc.name: Deserialize001
98  * @tc.desc: Test Deserialize
99  * @tc.type: FUNC
100  * @tc.require: I8VQSW
101  */
102 HWTEST_F(SkiaRegionTest, Deserialize001, TestSize.Level1)
103 {
104     std::shared_ptr<SkiaRegion> skiaRegion = std::make_shared<SkiaRegion>();
105     skiaRegion->Deserialize(nullptr);
106 }
107 
108 /**
109  * @tc.name: Contains001
110  * @tc.desc: Test Contains
111  * @tc.type: FUNC
112  * @tc.require: I8VQSW
113  */
114 HWTEST_F(SkiaRegionTest, Contains001, TestSize.Level1)
115 {
116     std::shared_ptr<SkiaRegion> skiaRegion = std::make_shared<SkiaRegion>();
117     RectI rect(0, 100, 100, 200);
118     skiaRegion->SetRect(rect);
119     auto ret = skiaRegion->Contains(300, 300); // 300, 300 is point
120     EXPECT_FALSE(ret);
121     ret = skiaRegion->Contains(50, 150); // 50, 100 is point
122     EXPECT_TRUE(ret);
123 }
124 } // namespace Drawing
125 } // namespace Rosen
126 } // namespace OHOS