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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/child/child_process.h" | 8 #include "content/child/child_process.h" |
9 #include "content/renderer/media/media_stream.h" | 9 #include "content/renderer/media/media_stream.h" |
10 #include "content/renderer/media/media_stream_impl.h" | 10 #include "content/renderer/media/media_stream_impl.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 desc.videoTracks(video_tracks); | 156 desc.videoTracks(video_tracks); |
157 | 157 |
158 EXPECT_EQ(1u, audio_tracks.size()); | 158 EXPECT_EQ(1u, audio_tracks.size()); |
159 EXPECT_EQ(1u, video_tracks.size()); | 159 EXPECT_EQ(1u, video_tracks.size()); |
160 EXPECT_NE(audio_tracks[0].id(), video_tracks[0].id()); | 160 EXPECT_NE(audio_tracks[0].id(), video_tracks[0].id()); |
161 return desc; | 161 return desc; |
162 } | 162 } |
163 | 163 |
164 void FakeMediaStreamDispatcherRequestUserMediaComplete() { | 164 void FakeMediaStreamDispatcherRequestUserMediaComplete() { |
165 // Audio request ID is used as the shared request ID. | 165 // Audio request ID is used as the shared request ID. |
166 ms_impl_->OnStreamGenerated(ms_dispatcher_->audio_input_request_id(), | 166 ms_impl_->OnStreamGenerated(ms_dispatcher_->audio_request_id(), |
167 ms_dispatcher_->stream_label(), | 167 ms_dispatcher_->stream_label(), |
168 ms_dispatcher_->audio_input_array(), | 168 ms_dispatcher_->audio_array(), |
169 ms_dispatcher_->video_array()); | 169 ms_dispatcher_->video_array()); |
170 } | 170 } |
171 | 171 |
172 void FakeMediaStreamDispatcherRequestMediaDevicesComplete() { | 172 void FakeMediaStreamDispatcherRequestMediaDevicesComplete() { |
173 ms_impl_->OnDevicesEnumerated(ms_dispatcher_->audio_input_request_id(), | 173 ms_impl_->OnDevicesEnumerated(ms_dispatcher_->audio_request_id(), |
174 ms_dispatcher_->audio_input_array()); | 174 ms_dispatcher_->audio_array()); |
175 ms_impl_->OnDevicesEnumerated(ms_dispatcher_->audio_output_request_id(), | |
176 ms_dispatcher_->audio_output_array()); | |
177 ms_impl_->OnDevicesEnumerated(ms_dispatcher_->video_request_id(), | 175 ms_impl_->OnDevicesEnumerated(ms_dispatcher_->video_request_id(), |
178 ms_dispatcher_->video_array()); | 176 ms_dispatcher_->video_array()); |
179 } | 177 } |
180 | 178 |
181 void StartMockedVideoSource() { | 179 void StartMockedVideoSource() { |
182 MockMediaStreamVideoCapturerSource* video_source = | 180 MockMediaStreamVideoCapturerSource* video_source = |
183 ms_impl_->last_created_video_source(); | 181 ms_impl_->last_created_video_source(); |
184 if (video_source->SourceHasAttemptedToStart()) | 182 if (video_source->SourceHasAttemptedToStart()) |
185 video_source->StartMockedSource(); | 183 video_source->StartMockedSource(); |
186 } | 184 } |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); | 428 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); |
431 } | 429 } |
432 | 430 |
433 TEST_F(MediaStreamImplTest, EnumerateMediaDevices) { | 431 TEST_F(MediaStreamImplTest, EnumerateMediaDevices) { |
434 ms_impl_->RequestMediaDevices(); | 432 ms_impl_->RequestMediaDevices(); |
435 FakeMediaStreamDispatcherRequestMediaDevicesComplete(); | 433 FakeMediaStreamDispatcherRequestMediaDevicesComplete(); |
436 | 434 |
437 EXPECT_EQ(MediaStreamImplUnderTest::REQUEST_SUCCEEDED, | 435 EXPECT_EQ(MediaStreamImplUnderTest::REQUEST_SUCCEEDED, |
438 ms_impl_->request_state()); | 436 ms_impl_->request_state()); |
439 | 437 |
440 // Audio input device with matched output ID. | |
441 EXPECT_FALSE(ms_impl_->last_devices()[0].deviceId().isEmpty()); | 438 EXPECT_FALSE(ms_impl_->last_devices()[0].deviceId().isEmpty()); |
442 EXPECT_EQ(blink::WebMediaDeviceInfo::MediaDeviceKindAudioInput, | 439 EXPECT_EQ(blink::WebMediaDeviceInfo::MediaDeviceKindAudioInput, |
443 ms_impl_->last_devices()[0].kind()); | 440 ms_impl_->last_devices()[0].kind()); |
444 EXPECT_FALSE(ms_impl_->last_devices()[0].label().isEmpty()); | 441 EXPECT_FALSE(ms_impl_->last_devices()[0].label().isEmpty()); |
445 EXPECT_FALSE(ms_impl_->last_devices()[0].groupId().isEmpty()); | |
446 | 442 |
447 // Audio input device without matched output ID. | |
448 EXPECT_FALSE(ms_impl_->last_devices()[1].deviceId().isEmpty()); | 443 EXPECT_FALSE(ms_impl_->last_devices()[1].deviceId().isEmpty()); |
449 EXPECT_EQ(blink::WebMediaDeviceInfo::MediaDeviceKindAudioInput, | 444 EXPECT_EQ(blink::WebMediaDeviceInfo::MediaDeviceKindVideoInput, |
450 ms_impl_->last_devices()[1].kind()); | 445 ms_impl_->last_devices()[1].kind()); |
451 EXPECT_FALSE(ms_impl_->last_devices()[1].label().isEmpty()); | 446 EXPECT_FALSE(ms_impl_->last_devices()[1].label().isEmpty()); |
452 EXPECT_FALSE(ms_impl_->last_devices()[1].groupId().isEmpty()); | |
453 | |
454 // Video input device. | |
455 EXPECT_FALSE(ms_impl_->last_devices()[2].deviceId().isEmpty()); | |
456 EXPECT_EQ(blink::WebMediaDeviceInfo::MediaDeviceKindVideoInput, | |
457 ms_impl_->last_devices()[2].kind()); | |
458 EXPECT_FALSE(ms_impl_->last_devices()[2].label().isEmpty()); | |
459 EXPECT_TRUE(ms_impl_->last_devices()[2].groupId().isEmpty()); | |
460 | |
461 // Audio output device. | |
462 EXPECT_FALSE(ms_impl_->last_devices()[3].deviceId().isEmpty()); | |
463 EXPECT_EQ(blink::WebMediaDeviceInfo::MediaDeviceKindAudioOutput, | |
464 ms_impl_->last_devices()[3].kind()); | |
465 EXPECT_FALSE(ms_impl_->last_devices()[3].label().isEmpty()); | |
466 EXPECT_FALSE(ms_impl_->last_devices()[3].groupId().isEmpty()); | |
467 | |
468 // Verfify group IDs. | |
469 EXPECT_TRUE(ms_impl_->last_devices()[0].groupId().equals( | |
470 ms_impl_->last_devices()[3].groupId())); | |
471 EXPECT_FALSE(ms_impl_->last_devices()[1].groupId().equals( | |
472 ms_impl_->last_devices()[3].groupId())); | |
473 } | 447 } |
474 | 448 |
475 } // namespace content | 449 } // namespace content |
OLD | NEW |