1 /* 2 * Copyright (c) 2021-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 #ifndef AUDIO_RENDERER_UNIT_TEST_H 17 #define AUDIO_RENDERER_UNIT_TEST_H 18 19 #include "gtest/gtest.h" 20 #include "audio_renderer.h" 21 22 namespace OHOS { 23 namespace AudioStandard { 24 class AudioRendererCallbackTest : public AudioRendererCallback { 25 public: OnInterrupt(const InterruptEvent & interruptEvent)26 void OnInterrupt(const InterruptEvent &interruptEvent) override {} OnStateChange(const RendererState state,const StateChangeCmdType cmdType)27 void OnStateChange(const RendererState state, const StateChangeCmdType cmdType) override {} 28 }; 29 30 class RendererPositionCallbackTest : public RendererPositionCallback { 31 public: OnMarkReached(const int64_t & framePosition)32 void OnMarkReached(const int64_t &framePosition) override {} 33 }; 34 35 class RendererPeriodPositionCallbackTest : public RendererPeriodPositionCallback { 36 public: OnPeriodReached(const int64_t & frameNumber)37 void OnPeriodReached(const int64_t &frameNumber) override {} 38 }; 39 40 class AudioRenderModeCallbackTest : public AudioRendererWriteCallback { 41 public: 42 void OnWriteData(size_t length) override; 43 }; 44 45 class AudioRendererUnitTest : 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 // Init Renderer 56 static int32_t InitializeRenderer(std::unique_ptr<AudioRenderer> &audioRenderer); 57 // Init Renderer Options 58 static void InitializeRendererOptions(AudioRendererOptions &rendererOptions); 59 }; 60 } // namespace AudioStandard 61 } // namespace OHOS 62 63 #endif // AUDIO_RENDERER_UNIT_TEST_H 64