OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "content/browser/browser_thread.h" | |
11 #include "content/browser/renderer_host/media/audio_input_device_manager.h" | 10 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
12 #include "content/browser/renderer_host/media/audio_input_device_manager_event_h
andler.h" | 11 #include "content/browser/renderer_host/media/audio_input_device_manager_event_h
andler.h" |
| 12 #include "content/test/test_browser_thread.h" |
13 #include "media/audio/audio_manager.h" | 13 #include "media/audio/audio_manager.h" |
14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 using ::testing::_; | 17 using ::testing::_; |
18 using ::testing::AnyNumber; | 18 using ::testing::AnyNumber; |
19 using ::testing::InSequence; | 19 using ::testing::InSequence; |
20 using ::testing::Return; | 20 using ::testing::Return; |
21 | 21 |
22 namespace media_stream { | 22 namespace media_stream { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 AudioInputDeviceManagerTest() | 78 AudioInputDeviceManagerTest() |
79 : message_loop_(), | 79 : message_loop_(), |
80 io_thread_(), | 80 io_thread_(), |
81 manager_(), | 81 manager_(), |
82 audio_input_listener_() {} | 82 audio_input_listener_() {} |
83 | 83 |
84 protected: | 84 protected: |
85 virtual void SetUp() { | 85 virtual void SetUp() { |
86 // The test must run on Browser::IO. | 86 // The test must run on Browser::IO. |
87 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); | 87 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); |
88 io_thread_.reset(new BrowserThread(BrowserThread::IO, message_loop_.get())); | 88 io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO, |
| 89 message_loop_.get())); |
89 manager_.reset(new media_stream::AudioInputDeviceManager()); | 90 manager_.reset(new media_stream::AudioInputDeviceManager()); |
90 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); | 91 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); |
91 manager_->Register(audio_input_listener_.get()); | 92 manager_->Register(audio_input_listener_.get()); |
92 | 93 |
93 // Get the enumerated device list from the AudioInputDeviceManager. | 94 // Get the enumerated device list from the AudioInputDeviceManager. |
94 manager_->EnumerateDevices(); | 95 manager_->EnumerateDevices(); |
95 EXPECT_CALL(*audio_input_listener_, DevicesEnumerated(_)) | 96 EXPECT_CALL(*audio_input_listener_, DevicesEnumerated(_)) |
96 .Times(1); | 97 .Times(1); |
97 // Sync up the threads to make sure we get the list. | 98 // Sync up the threads to make sure we get the list. |
98 SyncWithAudioInputDeviceManagerThread(); | 99 SyncWithAudioInputDeviceManagerThread(); |
(...skipping 21 matching lines...) Expand all Loading... |
120 // pending task in message_loop_ on the current thread. | 121 // pending task in message_loop_ on the current thread. |
121 void SyncWithAudioInputDeviceManagerThread() { | 122 void SyncWithAudioInputDeviceManagerThread() { |
122 message_loop_->PostTask( | 123 message_loop_->PostTask( |
123 FROM_HERE, | 124 FROM_HERE, |
124 base::Bind(&PostQuitOnAudioInputDeviceManagerThread, | 125 base::Bind(&PostQuitOnAudioInputDeviceManagerThread, |
125 message_loop_.get(), | 126 message_loop_.get(), |
126 manager_.get())); | 127 manager_.get())); |
127 message_loop_->Run(); | 128 message_loop_->Run(); |
128 } | 129 } |
129 scoped_ptr<MessageLoop> message_loop_; | 130 scoped_ptr<MessageLoop> message_loop_; |
130 scoped_ptr<BrowserThread> io_thread_; | 131 scoped_ptr<content::TestBrowserThread> io_thread_; |
131 scoped_ptr<AudioInputDeviceManager> manager_; | 132 scoped_ptr<AudioInputDeviceManager> manager_; |
132 scoped_ptr<MockAudioInputDeviceManagerListener> audio_input_listener_; | 133 scoped_ptr<MockAudioInputDeviceManagerListener> audio_input_listener_; |
133 | 134 |
134 private: | 135 private: |
135 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManagerTest); | 136 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManagerTest); |
136 }; | 137 }; |
137 | 138 |
138 // Test the devices can be opened and closed. | 139 // Test the devices can be opened and closed. |
139 TEST_F(AudioInputDeviceManagerTest, OpenAndCloseDevice) { | 140 TEST_F(AudioInputDeviceManagerTest, OpenAndCloseDevice) { |
140 if (!CanRunAudioInputDeviceTests()) | 141 if (!CanRunAudioInputDeviceTests()) |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 OnDeviceStarted(second_session_id, 0)) | 389 OnDeviceStarted(second_session_id, 0)) |
389 .Times(1); | 390 .Times(1); |
390 EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, first_session_id)) | 391 EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, first_session_id)) |
391 .Times(1); | 392 .Times(1); |
392 EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, second_session_id)) | 393 EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, second_session_id)) |
393 .Times(1); | 394 .Times(1); |
394 SyncWithAudioInputDeviceManagerThread(); | 395 SyncWithAudioInputDeviceManagerThread(); |
395 } | 396 } |
396 | 397 |
397 } // namespace media_stream | 398 } // namespace media_stream |
OLD | NEW |