• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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/sampling_options.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 SamplingOptionsTest : 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 SamplingOptionsTest::SetUpTestCase() {}
TearDownTestCase()36 void SamplingOptionsTest::TearDownTestCase() {}
SetUp()37 void SamplingOptionsTest::SetUp() {}
TearDown()38 void SamplingOptionsTest::TearDown() {}
39 
40 /**
41  * @tc.name: SamplingOptionsCreateAndDestroy001
42  * @tc.desc:
43  * @tc.type: FUNC
44  * @tc.require:AR000GGNV3
45  * @tc.author:
46  */
47 HWTEST_F(SamplingOptionsTest, SamplingOptionsCreateAndDestroy001, TestSize.Level1)
48 {
49     // The best way to create SamplingOptions.
50     std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>();
51     ASSERT_TRUE(sampling != nullptr);
52 }
53 
54 /**
55  * @tc.name: SamplingOptionsCreateAndDestroy002
56  * @tc.desc:
57  * @tc.type: FUNC
58  * @tc.require:AR000GGNV3
59  * @tc.author:
60  */
61 HWTEST_F(SamplingOptionsTest, SamplingOptionsCreateAndDestroy002, TestSize.Level1)
62 {
63     // The best way to create SamplingOptions.
64     CubicResampler cubicResampler;
65     std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>(cubicResampler);
66     ASSERT_TRUE(sampling != nullptr);
67 }
68 
69 /**
70  * @tc.name: SamplingOptionsGetUseCubic001
71  * @tc.desc:
72  * @tc.type: FUNC
73  * @tc.require:AR000GGNV3
74  * @tc.author:
75  */
76 HWTEST_F(SamplingOptionsTest, SamplingOptionsGetUseCubic001, TestSize.Level1)
77 {
78     std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>();
79     ASSERT_TRUE(sampling != nullptr);
80     ASSERT_EQ(false, sampling->GetUseCubic());
81 }
82 
83 /**
84  * @tc.name: SamplingOptionsGetFilterMode001
85  * @tc.desc:
86  * @tc.type: FUNC
87  * @tc.require:AR000GGNV3
88  * @tc.author:
89  */
90 HWTEST_F(SamplingOptionsTest, SamplingOptionsGetFilterMode001, TestSize.Level1)
91 {
92     std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>();
93     ASSERT_TRUE(sampling != nullptr);
94     ASSERT_EQ(FilterMode::NEAREST, sampling->GetFilterMode());
95 }
96 
97 /**
98  * @tc.name: SamplingOptionsGetMipmapMode001
99  * @tc.desc:
100  * @tc.type: FUNC
101  * @tc.require:AR000GGNV3
102  * @tc.author:
103  */
104 HWTEST_F(SamplingOptionsTest, SamplingOptionsGetMipmapMode001, TestSize.Level1)
105 {
106     std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>();
107     ASSERT_TRUE(sampling != nullptr);
108     ASSERT_EQ(MipmapMode::NONE, sampling->GetMipmapMode());
109 }
110 
111 /**
112  * @tc.name: SamplingOptionsGetCubicCoffB001
113  * @tc.desc:
114  * @tc.type: FUNC
115  * @tc.require:AR000GGNV3
116  * @tc.author:
117  */
118 HWTEST_F(SamplingOptionsTest, SamplingOptionsGetCubicCoffB001, TestSize.Level1)
119 {
120     std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>();
121     ASSERT_TRUE(sampling != nullptr);
122     ASSERT_EQ(0, sampling->GetCubicCoffB());
123 }
124 
125 /**
126  * @tc.name: SamplingOptionsGetCubicCoffB002
127  * @tc.desc:
128  * @tc.type: FUNC
129  * @tc.require:AR000GGNV3
130  * @tc.author:
131  */
132 HWTEST_F(SamplingOptionsTest, SamplingOptionsGetCubicCoffB002, TestSize.Level1)
133 {
134     CubicResampler cubicResampler;
135     std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>(cubicResampler);
136     ASSERT_TRUE(sampling != nullptr);
137     ASSERT_EQ(0, sampling->GetCubicCoffB());
138 }
139 
140 /**
141  * @tc.name: SamplingOptionsGetCubicCoffC001
142  * @tc.desc:
143  * @tc.type: FUNC
144  * @tc.require:AR000GGNV3
145  * @tc.author:
146  */
147 HWTEST_F(SamplingOptionsTest, SamplingOptionsGetCubicCoffC001, TestSize.Level1)
148 {
149     std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>();
150     ASSERT_TRUE(sampling != nullptr);
151     ASSERT_EQ(0, sampling->GetCubicCoffC());
152 }
153 
154 /**
155  * @tc.name: SamplingOptionsGetCubicCoffC002
156  * @tc.desc:
157  * @tc.type: FUNC
158  * @tc.require:AR000GGNV3
159  * @tc.author:
160  */
161 HWTEST_F(SamplingOptionsTest, SamplingOptionsGetCubicCoffC002, TestSize.Level1)
162 {
163     CubicResampler cubicResampler;
164     std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>(cubicResampler);
165     ASSERT_TRUE(sampling != nullptr);
166     ASSERT_EQ(0, sampling->GetCubicCoffC());
167 }
168 
169 /**
170  * @tc.name: SamplingOptionsEqual001
171  * @tc.desc:
172  * @tc.type: FUNC
173  * @tc.require:
174  * @tc.author:
175  */
176 HWTEST_F(SamplingOptionsTest, SamplingOptionsEqual001, TestSize.Level1)
177 {
178     SamplingOptions sampling1;
179     ASSERT_TRUE(sampling1 == sampling1);
180 }
181 
182 /**
183  * @tc.name: SamplingOptionsEqual002
184  * @tc.desc:
185  * @tc.type: FUNC
186  * @tc.require:
187  * @tc.author:
188  */
189 HWTEST_F(SamplingOptionsTest, SamplingOptionsEqual002, TestSize.Level1)
190 {
191     SamplingOptions sampling1;
192     SamplingOptions sampling2 = sampling1;
193     EXPECT_FALSE(sampling2 != sampling1);
194 }
195 
196 /**
197  * @tc.name: SamplingOptionsEqual003
198  * @tc.desc:
199  * @tc.type: FUNC
200  * @tc.require:
201  * @tc.author:
202  */
203 HWTEST_F(SamplingOptionsTest, SamplingOptionsEqual003, TestSize.Level1)
204 {
205     SamplingOptions sampling1;
206     SamplingOptions sampling2;
207     EXPECT_FALSE(sampling1 != sampling2);
208 }
209 } // namespace Drawing
210 } // namespace Rosen
211 } // namespace OHOS