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/browser/renderer_host/media/audio_input_device_manager_event_h
andler.h" | 13 #include "content/browser/renderer_host/media/audio_input_device_manager_event_h
andler.h" |
14 #include "content/public/common/media_stream_request.h" | 14 #include "content/public/common/media_stream_request.h" |
15 #include "media/audio/audio_manager_base.h" | 15 #include "media/audio/audio_manager_base.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 #if defined(OS_ANDROID) | |
20 #include "base/android/jni_android.h" | |
21 #include "media/audio/audio_manager_base.h" | |
22 #endif | |
23 | |
24 using testing::_; | 19 using testing::_; |
25 using testing::InSequence; | 20 using testing::InSequence; |
26 using testing::SaveArg; | 21 using testing::SaveArg; |
27 using testing::Return; | 22 using testing::Return; |
28 | 23 |
29 namespace content { | 24 namespace content { |
30 | 25 |
31 class MockAudioInputDeviceManagerListener | 26 class MockAudioInputDeviceManagerListener |
32 : public MediaStreamProviderListener { | 27 : public MediaStreamProviderListener { |
33 public: | 28 public: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 return audio_manager_->HasAudioInputDevices(); | 80 return audio_manager_->HasAudioInputDevices(); |
86 } | 81 } |
87 | 82 |
88 protected: | 83 protected: |
89 virtual void SetUp() OVERRIDE { | 84 virtual void SetUp() OVERRIDE { |
90 // The test must run on Browser::IO. | 85 // The test must run on Browser::IO. |
91 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); | 86 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); |
92 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, | 87 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, |
93 message_loop_.get())); | 88 message_loop_.get())); |
94 | 89 |
95 #if defined(OS_ANDROID) | |
96 media::AudioManagerBase::RegisterAudioManager( | |
97 base::android::AttachCurrentThread()); | |
98 #endif | |
99 | |
100 audio_manager_.reset(media::AudioManager::Create()); | 90 audio_manager_.reset(media::AudioManager::Create()); |
101 manager_ = new AudioInputDeviceManager(audio_manager_.get()); | 91 manager_ = new AudioInputDeviceManager(audio_manager_.get()); |
102 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); | 92 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); |
103 manager_->Register(audio_input_listener_.get(), | 93 manager_->Register(audio_input_listener_.get(), |
104 message_loop_->message_loop_proxy()); | 94 message_loop_->message_loop_proxy()); |
105 | 95 |
106 // Gets the enumerated device list from the AudioInputDeviceManager. | 96 // Gets the enumerated device list from the AudioInputDeviceManager. |
107 manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); | 97 manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); |
108 EXPECT_CALL(*audio_input_listener_, | 98 EXPECT_CALL(*audio_input_listener_, |
109 DevicesEnumerated(MEDIA_DEVICE_AUDIO_CAPTURE, _)) | 99 DevicesEnumerated(MEDIA_DEVICE_AUDIO_CAPTURE, _)) |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 469 |
480 manager_->Stop(session_id); | 470 manager_->Stop(session_id); |
481 manager_->Close(session_id); | 471 manager_->Close(session_id); |
482 EXPECT_CALL(*audio_input_listener_, | 472 EXPECT_CALL(*audio_input_listener_, |
483 Closed(MEDIA_DEVICE_AUDIO_CAPTURE, session_id)) | 473 Closed(MEDIA_DEVICE_AUDIO_CAPTURE, session_id)) |
484 .Times(1); | 474 .Times(1); |
485 message_loop_->RunUntilIdle(); | 475 message_loop_->RunUntilIdle(); |
486 } | 476 } |
487 | 477 |
488 } // namespace content | 478 } // namespace content |
OLD | NEW |