| 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 <unistd.h> | 5 #include <unistd.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "media/audio/cras/audio_manager_cras.h" | 12 #include "media/audio/cras/audio_manager_cras.h" |
| 13 #include "media/audio/cras/cras_input.h" | 13 #include "media/audio/cras/cras_input.h" |
| 14 #include "media/audio/fake_audio_log_factory.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 using testing::_; | 18 using testing::_; |
| 18 using testing::AtLeast; | 19 using testing::AtLeast; |
| 19 using testing::Ge; | 20 using testing::Ge; |
| 20 using testing::InvokeWithoutArgs; | 21 using testing::InvokeWithoutArgs; |
| 21 using testing::StrictMock; | 22 using testing::StrictMock; |
| 22 | 23 |
| 23 namespace media { | 24 namespace media { |
| 24 | 25 |
| 25 class MockAudioInputCallback : public AudioInputStream::AudioInputCallback { | 26 class MockAudioInputCallback : public AudioInputStream::AudioInputCallback { |
| 26 public: | 27 public: |
| 27 MOCK_METHOD5(OnData, void( | 28 MOCK_METHOD5(OnData, void( |
| 28 AudioInputStream*, const uint8*, uint32, uint32, double)); | 29 AudioInputStream*, const uint8*, uint32, uint32, double)); |
| 29 MOCK_METHOD1(OnError, void(AudioInputStream*)); | 30 MOCK_METHOD1(OnError, void(AudioInputStream*)); |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 class MockAudioManagerCrasInput : public AudioManagerCras { | 33 class MockAudioManagerCrasInput : public AudioManagerCras { |
| 33 public: | 34 public: |
| 35 MockAudioManagerCrasInput() : AudioManagerCras(&fake_audio_log_factory_) {} |
| 36 |
| 34 // We need to override this function in order to skip checking the number | 37 // We need to override this function in order to skip checking the number |
| 35 // of active output streams. It is because the number of active streams | 38 // of active output streams. It is because the number of active streams |
| 36 // is managed inside MakeAudioInputStream, and we don't use | 39 // is managed inside MakeAudioInputStream, and we don't use |
| 37 // MakeAudioInputStream to create the stream in the tests. | 40 // MakeAudioInputStream to create the stream in the tests. |
| 38 virtual void ReleaseInputStream(AudioInputStream* stream) OVERRIDE { | 41 virtual void ReleaseInputStream(AudioInputStream* stream) OVERRIDE { |
| 39 DCHECK(stream); | 42 DCHECK(stream); |
| 40 delete stream; | 43 delete stream; |
| 41 } | 44 } |
| 45 |
| 46 private: |
| 47 FakeAudioLogFactory fake_audio_log_factory_; |
| 42 }; | 48 }; |
| 43 | 49 |
| 44 class CrasInputStreamTest : public testing::Test { | 50 class CrasInputStreamTest : public testing::Test { |
| 45 protected: | 51 protected: |
| 46 CrasInputStreamTest() { | 52 CrasInputStreamTest() { |
| 47 mock_manager_.reset(new StrictMock<MockAudioManagerCrasInput>()); | 53 mock_manager_.reset(new StrictMock<MockAudioManagerCrasInput>()); |
| 48 } | 54 } |
| 49 | 55 |
| 50 virtual ~CrasInputStreamTest() { | 56 virtual ~CrasInputStreamTest() { |
| 51 } | 57 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 AudioParameters params_stereo(kTestFormat, | 208 AudioParameters params_stereo(kTestFormat, |
| 203 CHANNEL_LAYOUT_STEREO, | 209 CHANNEL_LAYOUT_STEREO, |
| 204 rates[i], | 210 rates[i], |
| 205 kTestBitsPerSample, | 211 kTestBitsPerSample, |
| 206 kTestFramesPerPacket); | 212 kTestFramesPerPacket); |
| 207 CaptureSomeFrames(params_stereo, kTestCaptureDurationMs); | 213 CaptureSomeFrames(params_stereo, kTestCaptureDurationMs); |
| 208 } | 214 } |
| 209 } | 215 } |
| 210 | 216 |
| 211 } // namespace media | 217 } // namespace media |
| OLD | NEW |