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, 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 "gtest/gtest.h"
17
18 #include "effect/mask_filter.h"
19
20 using namespace testing;
21 using namespace testing::ext;
22
23 namespace OHOS {
24 namespace Rosen {
25 namespace Drawing {
26 class MaskFilterTest : public testing::Test {
27 public:
28 static void SetUpTestCase();
29 static void TearDownTestCase();
30 void SetUp() override;
31 void TearDown() override;
32 };
33
SetUpTestCase()34 void MaskFilterTest::SetUpTestCase() {}
TearDownTestCase()35 void MaskFilterTest::TearDownTestCase() {}
SetUp()36 void MaskFilterTest::SetUp() {}
TearDown()37 void MaskFilterTest::TearDown() {}
38
39 /**
40 * @tc.name: CreateBlurMaskFilter001
41 * @tc.desc:
42 * @tc.type: FUNC
43 * @tc.require: AR000GGNV3
44 * @tc.author:
45 */
46 HWTEST_F(MaskFilterTest, CreateBlurMaskFilter001, TestSize.Level1)
47 {
48 auto maskFilter = MaskFilter::CreateBlurMaskFilter(BlurType::NORMAL, 0.5f);
49 EXPECT_TRUE(maskFilter != nullptr);
50 }
51
52 /**
53 * @tc.name: CreateBlurMaskFilter002
54 * @tc.desc:
55 * @tc.type: FUNC
56 * @tc.require: AR000GGNV3
57 * @tc.author:
58 */
59 HWTEST_F(MaskFilterTest, CreateBlurMaskFilter002, TestSize.Level1)
60 {
61 auto maskFilter = MaskFilter::CreateBlurMaskFilter(BlurType::OUTER, 0.2f);
62 EXPECT_TRUE(maskFilter != nullptr);
63 }
64
65 /**
66 * @tc.name: NoAgrsConstructor001
67 * @tc.desc:
68 * @tc.type: FUNC
69 * @tc.require: AR000GGNV3
70 * @tc.author:
71 */
72 HWTEST_F(MaskFilterTest, NoAgrsConstructor001, TestSize.Level1)
73 {
74 auto maskFilter = std::make_unique<MaskFilter>(MaskFilter::FilterType::BLUR, BlurType::NORMAL, 0.2f);
75 EXPECT_TRUE(maskFilter != nullptr);
76 }
77
78 /**
79 * @tc.name: NoAgrsConstructor002
80 * @tc.desc:
81 * @tc.type: FUNC
82 * @tc.require: AR000GGNV3
83 * @tc.author:
84 */
85 HWTEST_F(MaskFilterTest, NoAgrsConstructor002, TestSize.Level1)
86 {
87 auto maskFilter = std::make_unique<MaskFilter>(MaskFilter::FilterType::NO_TYPE, BlurType::NORMAL, 0.4f);
88 EXPECT_TRUE(maskFilter != nullptr);
89 }
90
91 /**
92 * @tc.name: AgrsConstructor001
93 * @tc.desc:
94 * @tc.type: FUNC
95 * @tc.require: AR000GGNV3
96 * @tc.author:
97 */
98 HWTEST_F(MaskFilterTest, AgrsConstructor001, TestSize.Level1)
99 {
100 MaskFilter::FilterType filterType = MaskFilter::FilterType::NO_TYPE;
101 auto maskFilter = std::make_unique<MaskFilter>(filterType, BlurType::SOLID, 0.5f);
102 ASSERT_TRUE(maskFilter != nullptr);
103 EXPECT_EQ(filterType, maskFilter->GetType());
104 }
105
106 /**
107 * @tc.name: AgrsConstructor002
108 * @tc.desc:
109 * @tc.type: FUNC
110 * @tc.require: AR000GGNV3
111 * @tc.author:
112 */
113 HWTEST_F(MaskFilterTest, AgrsConstructor002, TestSize.Level1)
114 {
115 MaskFilter::FilterType filterType = MaskFilter::FilterType::BLUR;
116 auto maskFilter = std::make_unique<MaskFilter>(filterType, BlurType::OUTER, 15.5f);
117 ASSERT_TRUE(maskFilter != nullptr);
118 EXPECT_EQ(filterType, maskFilter->GetType());
119 }
120 } // namespace Drawing
121 } // namespace Rosen
122 } // namespace OHOS
123