| 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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/synchronization/waitable_event.h" |
| 11 #include "content/browser/browser_thread_impl.h" | 12 #include "content/browser/browser_thread_impl.h" |
| 12 #include "content/browser/renderer_host/media/audio_input_device_manager.h" | 13 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
| 13 #include "content/public/common/media_stream_request.h" | 14 #include "content/public/common/media_stream_request.h" |
| 14 #include "media/audio/audio_manager_base.h" | 15 #include "media/audio/audio_manager_base.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 using testing::_; | 19 using testing::_; |
| 19 using testing::InSequence; | 20 using testing::InSequence; |
| 20 using testing::SaveArg; | 21 using testing::SaveArg; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 49 return audio_manager_->HasAudioInputDevices(); | 50 return audio_manager_->HasAudioInputDevices(); |
| 50 } | 51 } |
| 51 | 52 |
| 52 protected: | 53 protected: |
| 53 virtual void SetUp() OVERRIDE { | 54 virtual void SetUp() OVERRIDE { |
| 54 // The test must run on Browser::IO. | 55 // The test must run on Browser::IO. |
| 55 message_loop_.reset(new base::MessageLoopForIO); | 56 message_loop_.reset(new base::MessageLoopForIO); |
| 56 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, | 57 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, |
| 57 message_loop_.get())); | 58 message_loop_.get())); |
| 58 audio_manager_.reset(media::AudioManager::CreateForTesting()); | 59 audio_manager_.reset(media::AudioManager::CreateForTesting()); |
| 60 // Wait for audio thread initialization to complete. Otherwise the |
| 61 // enumeration type may not have been set yet. |
| 62 base::WaitableEvent event(false, false); |
| 63 audio_manager_->GetTaskRunner()->PostTask(FROM_HERE, base::Bind( |
| 64 &base::WaitableEvent::Signal, base::Unretained(&event))); |
| 65 event.Wait(); |
| 59 manager_ = new AudioInputDeviceManager(audio_manager_.get()); | 66 manager_ = new AudioInputDeviceManager(audio_manager_.get()); |
| 60 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); | 67 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); |
| 61 manager_->Register(audio_input_listener_.get(), | 68 manager_->Register(audio_input_listener_.get(), |
| 62 message_loop_->message_loop_proxy().get()); | 69 message_loop_->message_loop_proxy().get()); |
| 63 | 70 |
| 64 // Gets the enumerated device list from the AudioInputDeviceManager. | 71 // Gets the enumerated device list from the AudioInputDeviceManager. |
| 65 manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); | 72 manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); |
| 66 EXPECT_CALL(*audio_input_listener_, | 73 EXPECT_CALL(*audio_input_listener_, |
| 67 DevicesEnumerated(MEDIA_DEVICE_AUDIO_CAPTURE, _)) | 74 DevicesEnumerated(MEDIA_DEVICE_AUDIO_CAPTURE, _)) |
| 68 .Times(1) | 75 .Times(1) |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 DCHECK(!info); | 289 DCHECK(!info); |
| 283 | 290 |
| 284 manager_->Close(session_id); | 291 manager_->Close(session_id); |
| 285 EXPECT_CALL(*audio_input_listener_, | 292 EXPECT_CALL(*audio_input_listener_, |
| 286 Closed(MEDIA_DEVICE_AUDIO_CAPTURE, session_id)) | 293 Closed(MEDIA_DEVICE_AUDIO_CAPTURE, session_id)) |
| 287 .Times(1); | 294 .Times(1); |
| 288 message_loop_->RunUntilIdle(); | 295 message_loop_->RunUntilIdle(); |
| 289 } | 296 } |
| 290 | 297 |
| 291 } // namespace content | 298 } // namespace content |
| OLD | NEW |