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 #ifndef SUPER_RESOLUTION_POST_PROCESSOR_UNIT_TEST_H 16 #define SUPER_RESOLUTION_POST_PROCESSOR_UNIT_TEST_H 17 18 #include "gtest/gtest.h" 19 #include "mock/algorithm_video.h" 20 #include "super_resolution_post_processor.cpp" 21 22 namespace OHOS { 23 namespace Media { 24 namespace Pipeline { 25 26 class MockPostProcessorCallback : public PostProcessorCallback { 27 public: OnError(int32_t errorCode)28 void OnError(int32_t errorCode) override {} OnOutputFormatChanged(const Format & format)29 void OnOutputFormatChanged(const Format &format) override {} OnInputBufferAvailable(uint32_t index,std::shared_ptr<AVBuffer> buffer)30 void OnInputBufferAvailable(uint32_t index, std::shared_ptr<AVBuffer> buffer) override {} OnOutputBufferAvailable(uint32_t index,std::shared_ptr<AVBuffer> buffer)31 void OnOutputBufferAvailable(uint32_t index, std::shared_ptr<AVBuffer> buffer) override 32 { 33 buffer_ = buffer; 34 } 35 36 std::shared_ptr<AVBuffer> buffer_ {nullptr}; 37 }; 38 39 class MockEventReceiver : public EventReceiver { 40 public: 41 MockEventReceiver() = default; OnEvent(const Event & event)42 void OnEvent(const Event &event){}; 43 }; 44 45 class SuperResolutionPostProcessorUnitTest : public testing::Test { 46 public: 47 // SetUpTestCase: Called before all test cases 48 static void SetUpTestCase(void); 49 // TearDownTestCase: Called after all test case 50 static void TearDownTestCase(void); 51 // SetUp: Called before each test cases 52 void SetUp(void); 53 // TearDown: Called after each test cases 54 void TearDown(void); 55 56 protected: 57 std::shared_ptr<SuperResolutionPostProcessor> postProcessor_ { nullptr }; 58 std::shared_ptr<MockPostProcessorCallback> callback_ {nullptr}; 59 }; 60 } // namespace Pipeline 61 } // namespace Media 62 } // namespace OHOS 63 #endif // SUPER_RESOLUTION_POST_PROCESSOR_UNIT_TEST_H 64