| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "content/browser/browser_thread_impl.h" | 11 #include "content/browser/browser_thread_impl.h" |
| 12 #include "content/browser/renderer_host/media/audio_input_device_manager.h" | 12 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
| 13 #include "content/public/common/media_stream_request.h" | 13 #include "content/public/common/media_stream_request.h" |
| 14 #include "media/audio/audio_manager_base.h" | 14 #include "media/audio/audio_manager_base.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 #if defined(OS_ANDROID) |
| 19 #include "base/android/jni_android.h" |
| 20 #include "media/audio/audio_manager_base.h" |
| 21 #endif |
| 22 |
| 18 using testing::_; | 23 using testing::_; |
| 19 using testing::InSequence; | 24 using testing::InSequence; |
| 20 using testing::SaveArg; | 25 using testing::SaveArg; |
| 21 using testing::Return; | 26 using testing::Return; |
| 22 | 27 |
| 23 namespace content { | 28 namespace content { |
| 24 | 29 |
| 25 class MockAudioInputDeviceManagerListener | 30 class MockAudioInputDeviceManagerListener |
| 26 : public MediaStreamProviderListener { | 31 : public MediaStreamProviderListener { |
| 27 public: | 32 public: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 49 return audio_manager_->HasAudioInputDevices(); | 54 return audio_manager_->HasAudioInputDevices(); |
| 50 } | 55 } |
| 51 | 56 |
| 52 protected: | 57 protected: |
| 53 virtual void SetUp() OVERRIDE { | 58 virtual void SetUp() OVERRIDE { |
| 54 // The test must run on Browser::IO. | 59 // The test must run on Browser::IO. |
| 55 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); | 60 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); |
| 56 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, | 61 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, |
| 57 message_loop_.get())); | 62 message_loop_.get())); |
| 58 | 63 |
| 64 #if defined(OS_ANDROID) |
| 65 media::AudioManagerBase::RegisterAudioManager( |
| 66 base::android::AttachCurrentThread()); |
| 67 #endif |
| 68 |
| 59 audio_manager_.reset(media::AudioManager::Create()); | 69 audio_manager_.reset(media::AudioManager::Create()); |
| 60 manager_ = new AudioInputDeviceManager(audio_manager_.get()); | 70 manager_ = new AudioInputDeviceManager(audio_manager_.get()); |
| 61 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); | 71 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); |
| 62 manager_->Register(audio_input_listener_.get(), | 72 manager_->Register(audio_input_listener_.get(), |
| 63 message_loop_->message_loop_proxy()); | 73 message_loop_->message_loop_proxy()); |
| 64 | 74 |
| 65 // Gets the enumerated device list from the AudioInputDeviceManager. | 75 // Gets the enumerated device list from the AudioInputDeviceManager. |
| 66 manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); | 76 manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); |
| 67 EXPECT_CALL(*audio_input_listener_, | 77 EXPECT_CALL(*audio_input_listener_, |
| 68 DevicesEnumerated(MEDIA_DEVICE_AUDIO_CAPTURE, _)) | 78 DevicesEnumerated(MEDIA_DEVICE_AUDIO_CAPTURE, _)) |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 DCHECK(!info); | 293 DCHECK(!info); |
| 284 | 294 |
| 285 manager_->Close(session_id); | 295 manager_->Close(session_id); |
| 286 EXPECT_CALL(*audio_input_listener_, | 296 EXPECT_CALL(*audio_input_listener_, |
| 287 Closed(MEDIA_DEVICE_AUDIO_CAPTURE, session_id)) | 297 Closed(MEDIA_DEVICE_AUDIO_CAPTURE, session_id)) |
| 288 .Times(1); | 298 .Times(1); |
| 289 message_loop_->RunUntilIdle(); | 299 message_loop_->RunUntilIdle(); |
| 290 } | 300 } |
| 291 | 301 |
| 292 } // namespace content | 302 } // namespace content |
| OLD | NEW |