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 AudioRendererDeviceChangeCallbackTest : public AudioRendererDeviceChangeCallback { 31 public: OnStateChange(const DeviceInfo & deviceInfo)32 virtual void OnStateChange(const DeviceInfo &deviceInfo) override {} RemoveAllCallbacks()33 virtual void RemoveAllCallbacks() override {} 34 }; 35 36 class AudioRendererPolicyServiceDiedCallbackTest : public AudioRendererPolicyServiceDiedCallback { 37 public: OnAudioPolicyServiceDied()38 virtual void OnAudioPolicyServiceDied() override {} 39 }; 40 41 class RendererPositionCallbackTest : public RendererPositionCallback { 42 public: OnMarkReached(const int64_t & framePosition)43 void OnMarkReached(const int64_t &framePosition) override {} 44 }; 45 46 class RendererPeriodPositionCallbackTest : public RendererPeriodPositionCallback { 47 public: OnPeriodReached(const int64_t & frameNumber)48 void OnPeriodReached(const int64_t &frameNumber) override {} 49 }; 50 51 class AudioRenderModeCallbackTest : public AudioRendererWriteCallback { 52 public: 53 void OnWriteData(size_t length) override; 54 }; 55 56 class AudioRendererUnitTest : public testing::Test { 57 public: 58 // SetUpTestCase: Called before all test cases 59 static void SetUpTestCase(void); 60 // TearDownTestCase: Called after all test case 61 static void TearDownTestCase(void); 62 // SetUp: Called before each test cases 63 void SetUp(void); 64 // TearDown: Called after each test cases 65 void TearDown(void); 66 // Init Renderer 67 static int32_t InitializeRenderer(std::unique_ptr<AudioRenderer> &audioRenderer); 68 // Init Renderer Options 69 static void InitializeRendererOptions(AudioRendererOptions &rendererOptions); 70 }; 71 } // namespace AudioStandard 72 } // namespace OHOS 73 74 #endif // AUDIO_RENDERER_UNIT_TEST_H 75