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 "gtest/gtest.h" 17 18 #include "pipeline_core.h" 19 #include "effect.h" 20 #include "efilter_factory.h" 21 #include "test_common.h" 22 23 using namespace testing::ext; 24 25 namespace OHOS { 26 namespace Media { 27 namespace Effect { 28 namespace Test { 29 30 class TestEffectPipeline : public testing::Test { 31 public: 32 TestEffectPipeline() = default; 33 34 ~TestEffectPipeline() override = default; SetUpTestCase()35 static void SetUpTestCase() {} 36 TearDownTestCase()37 static void TearDownTestCase() {} 38 SetUp()39 void SetUp() override{} 40 TearDown()41 void TearDown() override{} 42 }; 43 44 HWTEST_F(TestEffectPipeline, EffectPipelineStandard001, TestSize.Level1) { 45 std::shared_ptr<PipelineCore> pipeline = std::make_shared<PipelineCore>(); 46 pipeline->Init(nullptr); 47 48 std::vector<Filter *> filtersToPipeline; 49 std::shared_ptr<EFilter> eFilter = EFilterFactory::Instance()->Create(BRIGHTNESS_EFILTER); 50 filtersToPipeline.push_back(eFilter.get()); 51 52 ErrorCode result = pipeline->AddFilters(filtersToPipeline); 53 EXPECT_EQ(result, ErrorCode::SUCCESS); 54 55 std::shared_ptr<EFilter> contrastEFilter = EFilterFactory::Instance()->Create(CONTRAST_EFILTER); 56 result = pipeline->AddFilter(contrastEFilter.get()); 57 EXPECT_EQ(result, ErrorCode::SUCCESS); 58 59 result = pipeline->LinkFilters(filtersToPipeline); 60 EXPECT_EQ(result, ErrorCode::SUCCESS); 61 62 result = pipeline->RemoveFilter(eFilter.get()); 63 EXPECT_EQ(result, ErrorCode::SUCCESS); 64 65 result = pipeline->RemoveFilterChain(contrastEFilter.get()); 66 EXPECT_EQ(result, ErrorCode::SUCCESS); 67 } 68 } 69 } 70 } 71 }