audio_system_impl_unittest.cc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "media/audio/audio_system_impl.h"
  5. #include "base/test/task_environment.h"
  6. #include "media/audio/audio_system_test_util.h"
  7. #include "media/audio/audio_thread_impl.h"
  8. #include "media/audio/mock_audio_manager.h"
  9. #include "media/audio/test_audio_thread.h"
  10. #include "testing/gtest/include/gtest/gtest.h"
  11. namespace media {
  12. // TODO(olka): These are the only tests for AudioSystemHelper. Make sure that
  13. // AudioSystemHelper is tested if AudioSystemImpl goes away.
  14. // Typed tests cannot be parametrized, so using template parameter instead of
  15. // inheriting from TestWithParams<>
  16. template <bool use_audio_thread>
  17. class AudioSystemImplTestBase : public testing::Test {
  18. public:
  19. AudioSystemImplTestBase() = default;
  20. ~AudioSystemImplTestBase() override = default;
  21. void SetUp() override {
  22. audio_manager_ = std::make_unique<MockAudioManager>(
  23. std::make_unique<TestAudioThread>(use_audio_thread));
  24. audio_system_ = std::make_unique<AudioSystemImpl>(audio_manager_.get());
  25. }
  26. void TearDown() override { audio_manager_->Shutdown(); }
  27. protected:
  28. MockAudioManager* audio_manager() { return audio_manager_.get(); }
  29. AudioSystem* audio_system() { return audio_system_.get(); }
  30. base::test::SingleThreadTaskEnvironment task_environment_;
  31. std::unique_ptr<MockAudioManager> audio_manager_;
  32. std::unique_ptr<AudioSystem> audio_system_;
  33. // AudioSystemTester tester_;
  34. };
  35. using AudioSystemTestBaseVariations =
  36. testing::Types<AudioSystemImplTestBase<false>,
  37. AudioSystemImplTestBase<true>>;
  38. INSTANTIATE_TYPED_TEST_SUITE_P(AudioSystemImpl,
  39. AudioSystemTestTemplate,
  40. AudioSystemTestBaseVariations);
  41. } // namespace media