OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "media/audio/cras/audio_manager_cras.h" | 10 #include "media/audio/cras/audio_manager_cras.h" |
11 #include "media/audio/cras/cras_unified.h" | |
12 #include "media/audio/fake_audio_log_factory.h" | 11 #include "media/audio/fake_audio_log_factory.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
15 | 14 |
15 // cras_util.h defines custom min/max macros which break compilation, so ensure | |
16 // it's not included until last. #if avoids presubmit errors. | |
17 #if defined(USE_CRAS) | |
18 #include "media/audio/cras/cras_unified.h" | |
19 #endif | |
20 | |
16 using testing::_; | 21 using testing::_; |
17 using testing::DoAll; | 22 using testing::DoAll; |
18 using testing::InvokeWithoutArgs; | 23 using testing::InvokeWithoutArgs; |
19 using testing::Return; | 24 using testing::Return; |
20 using testing::SetArgumentPointee; | 25 using testing::SetArgumentPointee; |
21 using testing::StrictMock; | 26 using testing::StrictMock; |
22 | 27 |
23 namespace media { | 28 namespace media { |
24 | 29 |
25 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { | 30 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { |
26 public: | 31 public: |
27 MOCK_METHOD2(OnMoreData, int(AudioBus* audio_bus, | 32 MOCK_METHOD2(OnMoreData, int(AudioBus* audio_bus, |
28 AudioBuffersState buffers_state)); | 33 AudioBuffersState buffers_state)); |
29 MOCK_METHOD3(OnMoreIOData, int(AudioBus* source, | 34 MOCK_METHOD3(OnMoreIOData, int(AudioBus* source, |
30 AudioBus* dest, | 35 AudioBus* dest, |
31 AudioBuffersState buffers_state)); | 36 AudioBuffersState buffers_state)); |
32 MOCK_METHOD1(OnError, void(AudioOutputStream* stream)); | 37 MOCK_METHOD1(OnError, void(AudioOutputStream* stream)); |
33 }; | 38 }; |
34 | 39 |
35 class MockAudioManagerCras : public AudioManagerCras { | 40 class MockAudioManagerCras : public AudioManagerCras { |
36 public: | 41 public: |
37 MockAudioManagerCras() : AudioManagerCras(&fake_audio_log_factory_) {} | 42 MockAudioManagerCras() : AudioManagerCras(&fake_audio_log_factory_) {} |
38 | 43 |
39 MOCK_METHOD0(Init, void()); | 44 MOCK_METHOD0(Init, void()); |
40 MOCK_METHOD0(HasAudioOutputDevices, bool()); | 45 MOCK_METHOD0(HasAudioOutputDevices, bool()); |
41 MOCK_METHOD0(HasAudioInputDevices, bool()); | 46 MOCK_METHOD0(HasAudioInputDevices, bool()); |
42 MOCK_METHOD1(MakeLinearOutputStream, AudioOutputStream*( | 47 MOCK_METHOD1(MakeLinearOutputStream, AudioOutputStream*( |
43 const AudioParameters& params)); | 48 const AudioParameters& params)); |
44 MOCK_METHOD1(MakeLowLatencyOutputStream, AudioOutputStream*( | 49 MOCK_METHOD3(MakeLowLatencyOutputStream, |
DaleCurtis
2014/01/10 19:44:14
I'm surprised this was broken... I guess we're not
| |
45 const AudioParameters& params)); | 50 AudioOutputStream*(const AudioParameters& params, |
51 const std::string& device_id, | |
52 const std::string& input_device_id)); | |
46 MOCK_METHOD2(MakeLinearOutputStream, AudioInputStream*( | 53 MOCK_METHOD2(MakeLinearOutputStream, AudioInputStream*( |
47 const AudioParameters& params, const std::string& device_id)); | 54 const AudioParameters& params, const std::string& device_id)); |
48 MOCK_METHOD2(MakeLowLatencyInputStream, AudioInputStream*( | 55 MOCK_METHOD2(MakeLowLatencyInputStream, AudioInputStream*( |
49 const AudioParameters& params, const std::string& device_id)); | 56 const AudioParameters& params, const std::string& device_id)); |
50 | 57 |
51 // We need to override this function in order to skip the checking the number | 58 // We need to override this function in order to skip the checking the number |
52 // of active output streams. It is because the number of active streams | 59 // of active output streams. It is because the number of active streams |
53 // is managed inside MakeAudioOutputStream, and we don't use | 60 // is managed inside MakeAudioOutputStream, and we don't use |
54 // MakeAudioOutputStream to create the stream in the tests. | 61 // MakeAudioOutputStream to create the stream in the tests. |
55 virtual void ReleaseOutputStream(AudioOutputStream* stream) OVERRIDE { | 62 virtual void ReleaseOutputStream(AudioOutputStream* stream) OVERRIDE { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 | 161 |
155 // Wait for samples to be captured. | 162 // Wait for samples to be captured. |
156 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_timeout())); | 163 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_timeout())); |
157 | 164 |
158 test_stream->Stop(); | 165 test_stream->Stop(); |
159 | 166 |
160 test_stream->Close(); | 167 test_stream->Close(); |
161 } | 168 } |
162 | 169 |
163 } // namespace media | 170 } // namespace media |
OLD | NEW |