| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/environment.h" | 12 #include "base/environment.h" |
| 13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
| 19 #include "base/test/test_timeouts.h" | 19 #include "base/test/test_timeouts.h" |
| 20 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
| 21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "media/audio/audio_device_description.h" | 23 #include "media/audio/audio_device_description.h" |
| 24 #include "media/audio/audio_io.h" | 24 #include "media/audio/audio_io.h" |
| 25 #include "media/audio/audio_unittest_util.h" | 25 #include "media/audio/audio_unittest_util.h" |
| 26 #include "media/audio/fake_audio_log_factory.h" | 26 #include "media/audio/fake_audio_log_factory.h" |
| 27 #include "media/audio/test_audio_thread.h" |
| 27 #include "media/base/seekable_buffer.h" | 28 #include "media/base/seekable_buffer.h" |
| 28 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 30 | 31 |
| 31 #if defined(USE_PULSEAUDIO) | 32 #if defined(USE_PULSEAUDIO) |
| 32 #include "media/audio/pulse/audio_manager_pulse.h" | 33 #include "media/audio/pulse/audio_manager_pulse.h" |
| 33 #elif defined(USE_ALSA) | 34 #elif defined(USE_ALSA) |
| 34 #include "media/audio/alsa/audio_manager_alsa.h" | 35 #include "media/audio/alsa/audio_manager_alsa.h" |
| 35 #elif defined(USE_CRAS) | 36 #elif defined(USE_CRAS) |
| 36 #include "media/audio/cras/audio_manager_cras.h" | 37 #include "media/audio/cras/audio_manager_cras.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 }; | 99 }; |
| 99 | 100 |
| 100 void OnLogMessage(const std::string& message) {} | 101 void OnLogMessage(const std::string& message) {} |
| 101 | 102 |
| 102 // This class mocks the platform specific audio manager and overrides | 103 // This class mocks the platform specific audio manager and overrides |
| 103 // the GetMessageLoop() method to ensure that we can run our tests on | 104 // the GetMessageLoop() method to ensure that we can run our tests on |
| 104 // the main thread instead of the audio thread. | 105 // the main thread instead of the audio thread. |
| 105 class MockAudioManager : public AudioManagerAnyPlatform { | 106 class MockAudioManager : public AudioManagerAnyPlatform { |
| 106 public: | 107 public: |
| 107 MockAudioManager() | 108 MockAudioManager() |
| 108 : AudioManagerAnyPlatform(base::ThreadTaskRunnerHandle::Get(), | 109 : AudioManagerAnyPlatform(base::MakeUnique<TestAudioThread>(), |
| 109 base::ThreadTaskRunnerHandle::Get(), | |
| 110 &fake_audio_log_factory_) {} | 110 &fake_audio_log_factory_) {} |
| 111 ~MockAudioManager() override {} | 111 ~MockAudioManager() override {} |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 FakeAudioLogFactory fake_audio_log_factory_; | 114 FakeAudioLogFactory fake_audio_log_factory_; |
| 115 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); | 115 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 // Test fixture class. | 118 // Test fixture class. |
| 119 class AudioLowLatencyInputOutputTest : public testing::Test { | 119 class AudioLowLatencyInputOutputTest : public testing::Test { |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 | 443 |
| 444 // All Close() operations that run on the mocked audio thread, | 444 // All Close() operations that run on the mocked audio thread, |
| 445 // should be synchronous and not post additional close tasks to | 445 // should be synchronous and not post additional close tasks to |
| 446 // mocked the audio thread. Hence, there is no need to call | 446 // mocked the audio thread. Hence, there is no need to call |
| 447 // message_loop()->RunUntilIdle() after the Close() methods. | 447 // message_loop()->RunUntilIdle() after the Close() methods. |
| 448 aos->Close(); | 448 aos->Close(); |
| 449 ais->Close(); | 449 ais->Close(); |
| 450 } | 450 } |
| 451 | 451 |
| 452 } // namespace media | 452 } // namespace media |
| OLD | NEW |