| 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/message_loop_proxy.h" |
| 6 #include "base/threading/platform_thread.h" | 7 #include "base/threading/platform_thread.h" |
| 7 #include "media/audio/audio_output_dispatcher.h" | 8 #include "media/audio/audio_output_dispatcher.h" |
| 8 #include "media/audio/audio_output_proxy.h" | 9 #include "media/audio/audio_output_proxy.h" |
| 9 #include "media/audio/audio_manager.h" | 10 #include "media/audio/audio_manager.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 13 |
| 13 using ::testing::_; | 14 using ::testing::_; |
| 14 using ::testing::Mock; | 15 using ::testing::Mock; |
| 15 using ::testing::Return; | 16 using ::testing::Return; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 43 MOCK_METHOD1(MakeAudioOutputStream, AudioOutputStream*( | 44 MOCK_METHOD1(MakeAudioOutputStream, AudioOutputStream*( |
| 44 const AudioParameters& params)); | 45 const AudioParameters& params)); |
| 45 MOCK_METHOD1(MakeAudioOutputStreamProxy, AudioOutputStream*( | 46 MOCK_METHOD1(MakeAudioOutputStreamProxy, AudioOutputStream*( |
| 46 const AudioParameters& params)); | 47 const AudioParameters& params)); |
| 47 MOCK_METHOD2(MakeAudioInputStream, AudioInputStream*( | 48 MOCK_METHOD2(MakeAudioInputStream, AudioInputStream*( |
| 48 const AudioParameters& params, const std::string& device_id)); | 49 const AudioParameters& params, const std::string& device_id)); |
| 49 MOCK_METHOD0(MuteAll, void()); | 50 MOCK_METHOD0(MuteAll, void()); |
| 50 MOCK_METHOD0(UnMuteAll, void()); | 51 MOCK_METHOD0(UnMuteAll, void()); |
| 51 MOCK_METHOD0(CanShowAudioInputSettings, bool()); | 52 MOCK_METHOD0(CanShowAudioInputSettings, bool()); |
| 52 MOCK_METHOD0(ShowAudioInputSettings, void()); | 53 MOCK_METHOD0(ShowAudioInputSettings, void()); |
| 53 MOCK_METHOD0(GetMessageLoop, MessageLoop*()); | 54 MOCK_METHOD0(GetMessageLoop, scoped_refptr<base::MessageLoopProxy>()); |
| 54 MOCK_METHOD1(GetAudioInputDeviceNames, void( | 55 MOCK_METHOD1(GetAudioInputDeviceNames, void( |
| 55 media::AudioDeviceNames* device_name)); | 56 media::AudioDeviceNames* device_name)); |
| 56 MOCK_METHOD0(IsRecordingInProcess, bool()); | 57 MOCK_METHOD0(IsRecordingInProcess, bool()); |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { | 60 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { |
| 60 public: | 61 public: |
| 61 MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, | 62 MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, |
| 62 uint8* dest, uint32 max_size, | 63 uint8* dest, uint32 max_size, |
| 63 AudioBuffersState buffers_state)); | 64 AudioBuffersState buffers_state)); |
| 64 MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); | 65 MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 class AudioOutputProxyTest : public testing::Test { | 68 class AudioOutputProxyTest : public testing::Test { |
| 68 protected: | 69 protected: |
| 69 virtual void SetUp() { | 70 virtual void SetUp() { |
| 70 MockAudioManager* manager = new MockAudioManager(); | 71 MockAudioManager* manager = new MockAudioManager(); |
| 71 EXPECT_CALL(*manager, GetMessageLoop()) | 72 EXPECT_CALL(*manager, GetMessageLoop()) |
| 72 .WillRepeatedly(Return(&message_loop_)); | 73 .WillRepeatedly(Return(message_loop_.message_loop_proxy())); |
| 73 manager_ = manager; | 74 manager_ = manager; |
| 74 InitDispatcher(base::TimeDelta::FromMilliseconds(kTestCloseDelayMs)); | 75 InitDispatcher(base::TimeDelta::FromMilliseconds(kTestCloseDelayMs)); |
| 75 } | 76 } |
| 76 | 77 |
| 77 virtual void TearDown() { | 78 virtual void TearDown() { |
| 78 // All paused proxies should have been closed at this point. | 79 // All paused proxies should have been closed at this point. |
| 79 EXPECT_EQ(0u, dispatcher_->paused_proxies_); | 80 EXPECT_EQ(0u, dispatcher_->paused_proxies_); |
| 80 | 81 |
| 81 // This is necessary to free all proxy objects that have been | 82 // This is necessary to free all proxy objects that have been |
| 82 // closed by the test. | 83 // closed by the test. |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 366 |
| 366 EXPECT_CALL(callback_, OnError(_, _)) | 367 EXPECT_CALL(callback_, OnError(_, _)) |
| 367 .Times(1); | 368 .Times(1); |
| 368 | 369 |
| 369 proxy->Start(&callback_); | 370 proxy->Start(&callback_); |
| 370 | 371 |
| 371 Mock::VerifyAndClear(&callback_); | 372 Mock::VerifyAndClear(&callback_); |
| 372 | 373 |
| 373 proxy->Close(); | 374 proxy->Close(); |
| 374 } | 375 } |
| OLD | NEW |