1 /* 2 * Copyright (c) 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_STREAM_MANAGER_UNIT_TEST_H 17 #define AUDIO_STREAM_MANAGER_UNIT_TEST_H 18 19 #include "gtest/gtest.h" 20 #include "audio_capturer.h" 21 #include "audio_renderer.h" 22 #include "audio_stream_manager.h" 23 24 namespace OHOS { 25 namespace AudioStandard { 26 class AudioRendererStateChangeCallbackTest : public AudioRendererStateChangeCallback { 27 public: 28 explicit AudioRendererStateChangeCallbackTest(const std::string &testCaseName); 29 ~AudioRendererStateChangeCallbackTest() = default; 30 31 void OnRendererStateChange( 32 const std::vector<std::unique_ptr<AudioRendererChangeInfo>> &audioRendererChangeInfos) override; 33 private: 34 std::string testCaseName_; 35 }; 36 37 class AudioCapturerStateChangeCallbackTest : public AudioCapturerStateChangeCallback { 38 public: 39 explicit AudioCapturerStateChangeCallbackTest(const std::string &testCaseName); 40 ~AudioCapturerStateChangeCallbackTest() = default; 41 42 void OnCapturerStateChange( 43 const std::vector<std::unique_ptr<AudioCapturerChangeInfo>> &audioCapturerChangeInfos) override; 44 private: 45 std::string testCaseName_; 46 }; 47 48 class AudioStreamManagerUnitTest : public testing::Test { 49 public: 50 // SetUpTestCase: Called before all test cases 51 static void SetUpTestCase(void); 52 // TearDownTestCase: Called after all test case 53 static void TearDownTestCase(void); 54 // SetUp: Called before each test cases 55 void SetUp(void); 56 // TearDown: Called after each test cases 57 void TearDown(void); 58 // Init Renderer Options 59 static void InitializeRendererOptions(AudioRendererOptions &rendererOptions); 60 // Init Capturer Options 61 static void InitializeCapturerOptions(AudioCapturerOptions &capturerOptions); 62 // Wait for Callback invoke 63 static void WaitForCallback(); 64 }; 65 } // namespace AudioStandard 66 } // namespace OHOS 67 68 #endif // AUDIO_STREAM_MANAGER_UNIT_TEST_H 69