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 "base/environment.h" | 8 #include "base/environment.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "base/test/test_timeouts.h" | 14 #include "base/test/test_timeouts.h" |
15 #include "base/thread_task_runner_handle.h" | |
16 #include "base/time/time.h" | 15 #include "base/time/time.h" |
17 #include "build/build_config.h" | 16 #include "build/build_config.h" |
18 #include "media/audio/audio_io.h" | 17 #include "media/audio/audio_io.h" |
19 #include "media/audio/audio_manager_base.h" | 18 #include "media/audio/audio_manager_base.h" |
20 #include "media/audio/audio_unittest_util.h" | 19 #include "media/audio/audio_unittest_util.h" |
21 #include "media/audio/fake_audio_log_factory.h" | 20 #include "media/audio/fake_audio_log_factory.h" |
22 #include "media/base/seekable_buffer.h" | 21 #include "media/base/seekable_buffer.h" |
23 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
25 | 24 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 89 |
91 // Reported render/output delay. Typical value is ~40 [ms]. | 90 // Reported render/output delay. Typical value is ~40 [ms]. |
92 int output_delay_ms; | 91 int output_delay_ms; |
93 }; | 92 }; |
94 | 93 |
95 // This class mocks the platform specific audio manager and overrides | 94 // This class mocks the platform specific audio manager and overrides |
96 // the GetMessageLoop() method to ensure that we can run our tests on | 95 // the GetMessageLoop() method to ensure that we can run our tests on |
97 // the main thread instead of the audio thread. | 96 // the main thread instead of the audio thread. |
98 class MockAudioManager : public AudioManagerAnyPlatform { | 97 class MockAudioManager : public AudioManagerAnyPlatform { |
99 public: | 98 public: |
100 MockAudioManager() | 99 MockAudioManager() : AudioManagerAnyPlatform(&fake_audio_log_factory_) {} |
101 : AudioManagerAnyPlatform(base::ThreadTaskRunnerHandle::Get(), | |
102 base::ThreadTaskRunnerHandle::Get(), | |
103 &fake_audio_log_factory_) {} | |
104 ~MockAudioManager() override {} | 100 ~MockAudioManager() override {} |
105 | 101 |
| 102 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() override { |
| 103 return base::MessageLoop::current()->task_runner(); |
| 104 } |
| 105 |
106 private: | 106 private: |
107 FakeAudioLogFactory fake_audio_log_factory_; | 107 FakeAudioLogFactory fake_audio_log_factory_; |
108 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); | 108 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); |
109 }; | 109 }; |
110 | 110 |
111 // Test fixture class. | 111 // Test fixture class. |
112 class AudioLowLatencyInputOutputTest : public testing::Test { | 112 class AudioLowLatencyInputOutputTest : public testing::Test { |
113 protected: | 113 protected: |
114 AudioLowLatencyInputOutputTest() {} | 114 AudioLowLatencyInputOutputTest() {} |
115 | 115 |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 | 433 |
434 // All Close() operations that run on the mocked audio thread, | 434 // All Close() operations that run on the mocked audio thread, |
435 // should be synchronous and not post additional close tasks to | 435 // should be synchronous and not post additional close tasks to |
436 // mocked the audio thread. Hence, there is no need to call | 436 // mocked the audio thread. Hence, there is no need to call |
437 // message_loop()->RunUntilIdle() after the Close() methods. | 437 // message_loop()->RunUntilIdle() after the Close() methods. |
438 aos->Close(); | 438 aos->Close(); |
439 ais->Close(); | 439 ais->Close(); |
440 } | 440 } |
441 | 441 |
442 } // namespace media | 442 } // namespace media |
OLD | NEW |