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" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 MessageLoop* message_loop_; | 80 MessageLoop* message_loop_; |
81 DISALLOW_COPY_AND_ASSIGN(MockAudioInputDeviceManagerEventHandler); | 81 DISALLOW_COPY_AND_ASSIGN(MockAudioInputDeviceManagerEventHandler); |
82 }; | 82 }; |
83 | 83 |
84 ACTION_P(ExitMessageLoop, message_loop) { | 84 ACTION_P(ExitMessageLoop, message_loop) { |
85 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 85 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
86 } | 86 } |
87 | 87 |
88 class AudioInputDeviceManagerTest : public testing::Test { | 88 class AudioInputDeviceManagerTest : public testing::Test { |
89 public: | 89 public: |
90 AudioInputDeviceManagerTest() | 90 AudioInputDeviceManagerTest() {} |
91 : message_loop_(), | |
92 io_thread_(), | |
93 manager_(), | |
94 audio_input_listener_() { | |
95 } | |
96 | 91 |
97 // Returns true iff machine has an audio input device. | 92 // Returns true iff machine has an audio input device. |
98 bool CanRunAudioInputDeviceTests() { | 93 bool CanRunAudioInputDeviceTests() { |
99 return audio_manager_->HasAudioInputDevices(); | 94 return audio_manager_->HasAudioInputDevices(); |
100 } | 95 } |
101 | 96 |
102 protected: | 97 protected: |
103 virtual void SetUp() { | 98 virtual void SetUp() OVERRIDE { |
104 // The test must run on Browser::IO. | 99 // The test must run on Browser::IO. |
105 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); | 100 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); |
106 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, | 101 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, |
107 message_loop_.get())); | 102 message_loop_.get())); |
| 103 |
108 audio_manager_.reset(media::AudioManager::Create()); | 104 audio_manager_.reset(media::AudioManager::Create()); |
109 | |
110 manager_ = new AudioInputDeviceManager(audio_manager_.get()); | 105 manager_ = new AudioInputDeviceManager(audio_manager_.get()); |
111 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); | 106 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); |
112 manager_->Register(audio_input_listener_.get()); | 107 manager_->Register(audio_input_listener_.get(), |
| 108 message_loop_->message_loop_proxy()); |
113 | 109 |
114 // Gets the enumerated device list from the AudioInputDeviceManager. | 110 // Gets the enumerated device list from the AudioInputDeviceManager. |
115 manager_->EnumerateDevices(); | 111 manager_->EnumerateDevices(); |
116 EXPECT_CALL(*audio_input_listener_, DevicesEnumerated(_)) | 112 EXPECT_CALL(*audio_input_listener_, DevicesEnumerated(_)) |
117 .Times(1); | 113 .Times(1); |
118 | 114 |
119 // Waits for the callback. | 115 // Wait until we get the list. |
120 message_loop_->RunAllPending(); | 116 message_loop_->RunAllPending(); |
121 } | 117 } |
122 | 118 |
123 virtual void TearDown() { | 119 virtual void TearDown() OVERRIDE { |
124 manager_->Unregister(); | 120 manager_->Unregister(); |
125 io_thread_.reset(); | 121 io_thread_.reset(); |
126 } | 122 } |
127 | 123 |
128 scoped_ptr<MessageLoop> message_loop_; | 124 scoped_ptr<MessageLoop> message_loop_; |
129 scoped_ptr<BrowserThreadImpl> io_thread_; | 125 scoped_ptr<BrowserThreadImpl> io_thread_; |
130 scoped_refptr<AudioInputDeviceManager> manager_; | 126 scoped_refptr<AudioInputDeviceManager> manager_; |
131 scoped_ptr<MockAudioInputDeviceManagerListener> audio_input_listener_; | 127 scoped_ptr<MockAudioInputDeviceManagerListener> audio_input_listener_; |
132 scoped_ptr<media::AudioManager> audio_manager_; | 128 scoped_ptr<media::AudioManager> audio_manager_; |
133 | 129 |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 manager_->Stop(session_id); | 512 manager_->Stop(session_id); |
517 manager_->Close(session_id); | 513 manager_->Close(session_id); |
518 EXPECT_CALL(*audio_input_listener_, | 514 EXPECT_CALL(*audio_input_listener_, |
519 Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, | 515 Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, |
520 session_id)) | 516 session_id)) |
521 .Times(1); | 517 .Times(1); |
522 message_loop_->RunAllPending(); | 518 message_loop_->RunAllPending(); |
523 } | 519 } |
524 | 520 |
525 } // namespace media_stream | 521 } // namespace media_stream |
OLD | NEW |