• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 "post_processor_factory_unit_test.h"
17 
18 #include "gmock/gmock.h"
19 
20 using namespace OHOS;
21 using namespace OHOS::Media;
22 using namespace std;
23 using namespace testing;
24 using namespace testing::ext;
25 
26 namespace OHOS {
27 namespace Media {
28 
SetUpTestCase(void)29 void PostProcessorFacotoryUnitTest::SetUpTestCase(void) {}
30 
TearDownTestCase(void)31 void PostProcessorFacotoryUnitTest::TearDownTestCase(void) {}
32 
SetUp(void)33 void PostProcessorFacotoryUnitTest::SetUp(void)
34 {
35     factory_ = std::make_shared<VideoPostProcessorFactory>();
36     EXPECT_NE(factory_, nullptr);
37 }
38 
TearDown(void)39 void PostProcessorFacotoryUnitTest::TearDown(void)
40 {
41     factory_ = nullptr;
42 }
43 
44 HWTEST_F(PostProcessorFacotoryUnitTest, PostProcessorFacotory_001, TestSize.Level1)
45 {
46     std::shared_ptr<Meta> meta;
47     EXPECT_EQ(factory_->CreateVideoPostProcessorPriv(VideoPostProcessorType::NONE), nullptr);
48     EXPECT_EQ(factory_->IsPostProcessorSupportedPriv(VideoPostProcessorType::NONE, meta), false);
49 }
50 
51 HWTEST_F(PostProcessorFacotoryUnitTest, PostProcessorFacotory_002, TestSize.Level1)
52 {
53     std::shared_ptr<Meta> meta;
54     VideoPostProcessorInstanceGenerator generator = nullptr;
55     VideoPostProcessorSupportChecker checker = nullptr;
56     factory_->RegisterPostProcessor<MockPostProcessor>(VideoPostProcessorType::NONE, generator);
57     factory_->RegisterChecker(VideoPostProcessorType::NONE, checker);
58     EXPECT_NE(factory_->CreateVideoPostProcessorPriv(VideoPostProcessorType::NONE), nullptr);
59     EXPECT_EQ(factory_->IsPostProcessorSupportedPriv(VideoPostProcessorType::NONE, meta), true);
60 }
61 
62 HWTEST_F(PostProcessorFacotoryUnitTest, PostProcessorFacotory_003, TestSize.Level1)
63 {
64     std::shared_ptr<Meta> meta;
__anon591a916a0102() 65     VideoPostProcessorInstanceGenerator generator = []() -> std::shared_ptr<BaseVideoPostProcessor> {
66         return std::make_shared<MockPostProcessor>();
67     };
__anon591a916a0202(const std::shared_ptr<Meta>& meta) 68     VideoPostProcessorSupportChecker checker = [](const std::shared_ptr<Meta>& meta) -> bool {
69         return true;
70     };
71     factory_->RegisterPostProcessor<MockPostProcessor>(VideoPostProcessorType::NONE, generator);
72     factory_->RegisterChecker(VideoPostProcessorType::NONE, checker);
73     EXPECT_NE(factory_->CreateVideoPostProcessorPriv(VideoPostProcessorType::NONE), nullptr);
74     EXPECT_EQ(factory_->IsPostProcessorSupportedPriv(VideoPostProcessorType::NONE, meta), true);
75 }
76 
77 HWTEST_F(PostProcessorFacotoryUnitTest, PostProcessorFacotory_004, TestSize.Level1)
78 {
79     std::shared_ptr<Meta> meta;
__anon591a916a0302() 80     VideoPostProcessorInstanceGenerator generator = []() -> std::shared_ptr<BaseVideoPostProcessor> {
81         return nullptr;
82     };
__anon591a916a0402(const std::shared_ptr<Meta>& meta) 83     VideoPostProcessorSupportChecker checker = [](const std::shared_ptr<Meta>& meta) -> bool {
84         return false;
85     };
86     factory_->RegisterPostProcessor<MockPostProcessor>(VideoPostProcessorType::NONE, generator);
87     factory_->RegisterChecker(VideoPostProcessorType::NONE, checker);
88     EXPECT_EQ(factory_->CreateVideoPostProcessorPriv(VideoPostProcessorType::NONE), nullptr);
89     EXPECT_EQ(factory_->IsPostProcessorSupportedPriv(VideoPostProcessorType::NONE, meta), false);
90 }
91 
92 }  // namespace Media
93 }  // namespace OHOS