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 "algo_filter_unittest.h" 17 #include "filter_factory.h" 18 19 using namespace testing; 20 using namespace testing::ext; 21 22 namespace OHOS { 23 namespace Rosen { 24 /** 25 * @tc.name: GetFilterTypeTest001 26 * @tc.desc: Obtain the type of filter according to different implementations of the interface 27 * @tc.type: FUNC 28 * @tc.require: 29 * @tc.author: 30 */ 31 HWTEST_F(AlgoFilterUnittest, GetFilterTypeTest001, TestSize.Level1) 32 { 33 GTEST_LOG_(INFO) << "AlgoFilterUnittest GetFilterTypeTest001 start"; 34 /** 35 * @tc.steps: step1. Create a Filter pointer 36 */ 37 FilterFactory filterFactory; 38 auto gaussian = filterFactory.GetFilter("GaussianBlur"); 39 /** 40 * @tc.steps: step2. Call GetFilterType to get the type of Filter 41 */ 42 auto type = gaussian->GetFilterType(); 43 EXPECT_EQ(type, FILTER_TYPE::ALGOFILTER); 44 } 45 46 /** 47 * @tc.name: GetFilterTypeTest002 48 * @tc.desc: Obtain the type of filter according to different implementations of the interface 49 * @tc.type: FUNC 50 * @tc.require: 51 * @tc.author: 52 */ 53 HWTEST_F(AlgoFilterUnittest, GetFilterTypeTest002, TestSize.Level1) 54 { 55 GTEST_LOG_(INFO) << "AlgoFilterUnittest GetFilterTypeTest002 start"; 56 /** 57 * @tc.steps: step1. Create a Filter pointer 58 */ 59 FilterFactory filterFactory; 60 auto horizon = filterFactory.GetFilter("HorizontalBlur"); 61 /** 62 * @tc.steps: step2. Call GetFilterType to get the type of Filter 63 */ 64 auto type = horizon->GetFilterType(); 65 EXPECT_EQ(type, FILTER_TYPE::ALGOFILTER); 66 } 67 68 /** 69 * @tc.name: GetFilterTypeTest003 70 * @tc.desc: Obtain the type of filter according to different implementations of the interface 71 * @tc.type: FUNC 72 * @tc.require: 73 * @tc.author: 74 */ 75 HWTEST_F(AlgoFilterUnittest, GetFilterTypeTest003, TestSize.Level1) 76 { 77 GTEST_LOG_(INFO) << "AlgoFilterUnittest GetFilterTypeTest003 start"; 78 /** 79 * @tc.steps: step1. Create a Filter pointer 80 */ 81 FilterFactory filterFactory; 82 auto brightness = filterFactory.GetFilter("Brightness"); 83 /** 84 * @tc.steps: step2. Call GetFilterType to get the type of Filter 85 */ 86 auto type = brightness->GetFilterType(); 87 EXPECT_EQ(type, FILTER_TYPE::ALGOFILTER); 88 } 89 90 /** 91 * @tc.name: SetValue001 92 * @tc.desc: Set some parameters required when the program is compiled 93 * @tc.type: FUNC 94 * @tc.require: 95 * @tc.author: 96 */ 97 HWTEST_F(AlgoFilterUnittest, SetValue001, TestSize.Level1) 98 { 99 GTEST_LOG_(INFO) << "AlgoFilterUnittest SetValue001 start"; 100 /** 101 * @tc.steps: step1. Create a Filter pointer 102 */ 103 FilterFactory filterFactory; 104 auto brightness = filterFactory.GetFilter("Brightness"); 105 bool testResult = brightness != nullptr; 106 EXPECT_TRUE(testResult); 107 /** 108 * @tc.steps: step2. Call SetValue to set the necessary values 109 */ 110 std::shared_ptr<float> sBright = std::make_shared<float>(0.5f); 111 std::weak_ptr<void> vBright = sBright; 112 brightness->SetValue("brightness", vBright.lock(), 1); 113 } 114 115 /** 116 * @tc.name: SetValue002 117 * @tc.desc: Set some parameters required when the program is compiled 118 * @tc.type: FUNC 119 * @tc.require: 120 * @tc.author: 121 */ 122 HWTEST_F(AlgoFilterUnittest, SetValue002, TestSize.Level1) 123 { 124 GTEST_LOG_(INFO) << "AlgoFilterUnittest SetValue002 start"; 125 /** 126 * @tc.steps: step1. Create a Filter pointer 127 */ 128 FilterFactory filterFactory; 129 auto saturation = filterFactory.GetFilter("Saturation"); 130 bool testResult = saturation != nullptr; 131 EXPECT_TRUE(testResult); 132 /** 133 * @tc.steps: step2. Call SetValue to set the necessary values 134 */ 135 std::shared_ptr<float> sSaturation = std::make_shared<float>(0.5f); 136 std::weak_ptr<void> vSaturation = sSaturation; 137 saturation->SetValue("saturation", vSaturation.lock(), 1); 138 } 139 140 /** 141 * @tc.name: SetValue003 142 * @tc.desc: Set some parameters required when the program is compiled 143 * @tc.type: FUNC 144 * @tc.require: 145 * @tc.author: 146 */ 147 HWTEST_F(AlgoFilterUnittest, SetValue003, TestSize.Level1) 148 { 149 GTEST_LOG_(INFO) << "AlgoFilterUnittest SetValue003 start"; 150 /** 151 * @tc.steps: step1. Create a Filter pointer 152 */ 153 FilterFactory filterFactory; 154 auto contrast = filterFactory.GetFilter("Contrast"); 155 bool testResult = contrast != nullptr; 156 EXPECT_TRUE(testResult); 157 /** 158 * @tc.steps: step2. Call SetValue to set the necessary values 159 */ 160 std::shared_ptr<float> sContrast = std::make_shared<float>(0.6f); 161 std::weak_ptr<void> vContrast = sContrast; 162 contrast->SetValue("contrast", vContrast.lock(), 1); 163 } 164 } // namespace Rosen 165 } // namespace OHOS 166