Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: content/renderer/media/media_stream_impl_unittest.cc

Issue 312773002: Support for audio output devices for getMediaDevices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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_request_id(), 166 ms_impl_->OnStreamGenerated(ms_dispatcher_->audio_input_request_id(),
167 ms_dispatcher_->stream_label(), 167 ms_dispatcher_->stream_label(),
168 ms_dispatcher_->audio_array(), 168 ms_dispatcher_->audio_input_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_request_id(), 173 ms_impl_->OnDevicesEnumerated(ms_dispatcher_->audio_input_request_id(),
174 ms_dispatcher_->audio_array()); 174 ms_dispatcher_->audio_input_array());
175 ms_impl_->OnDevicesEnumerated(ms_dispatcher_->audio_output_request_id(),
176 ms_dispatcher_->audio_output_array());
175 ms_impl_->OnDevicesEnumerated(ms_dispatcher_->video_request_id(), 177 ms_impl_->OnDevicesEnumerated(ms_dispatcher_->video_request_id(),
176 ms_dispatcher_->video_array()); 178 ms_dispatcher_->video_array());
177 } 179 }
178 180
179 void StartMockedVideoSource() { 181 void StartMockedVideoSource() {
180 MockMediaStreamVideoCapturerSource* video_source = 182 MockMediaStreamVideoCapturerSource* video_source =
181 ms_impl_->last_created_video_source(); 183 ms_impl_->last_created_video_source();
182 if (video_source->SourceHasAttemptedToStart()) 184 if (video_source->SourceHasAttemptedToStart())
183 video_source->StartMockedSource(); 185 video_source->StartMockedSource();
184 } 186 }
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); 430 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter());
429 } 431 }
430 432
431 TEST_F(MediaStreamImplTest, EnumerateMediaDevices) { 433 TEST_F(MediaStreamImplTest, EnumerateMediaDevices) {
432 ms_impl_->RequestMediaDevices(); 434 ms_impl_->RequestMediaDevices();
433 FakeMediaStreamDispatcherRequestMediaDevicesComplete(); 435 FakeMediaStreamDispatcherRequestMediaDevicesComplete();
434 436
435 EXPECT_EQ(MediaStreamImplUnderTest::REQUEST_SUCCEEDED, 437 EXPECT_EQ(MediaStreamImplUnderTest::REQUEST_SUCCEEDED,
436 ms_impl_->request_state()); 438 ms_impl_->request_state());
437 439
440 // Audio input device with matched output ID.
438 EXPECT_FALSE(ms_impl_->last_devices()[0].deviceId().isEmpty()); 441 EXPECT_FALSE(ms_impl_->last_devices()[0].deviceId().isEmpty());
439 EXPECT_EQ(blink::WebMediaDeviceInfo::MediaDeviceKindAudioInput, 442 EXPECT_EQ(blink::WebMediaDeviceInfo::MediaDeviceKindAudioInput,
440 ms_impl_->last_devices()[0].kind()); 443 ms_impl_->last_devices()[0].kind());
441 EXPECT_FALSE(ms_impl_->last_devices()[0].label().isEmpty()); 444 EXPECT_FALSE(ms_impl_->last_devices()[0].label().isEmpty());
445 EXPECT_FALSE(ms_impl_->last_devices()[0].groupId().isEmpty());
442 446
447 // Audio input device without matched output ID.
443 EXPECT_FALSE(ms_impl_->last_devices()[1].deviceId().isEmpty()); 448 EXPECT_FALSE(ms_impl_->last_devices()[1].deviceId().isEmpty());
444 EXPECT_EQ(blink::WebMediaDeviceInfo::MediaDeviceKindVideoInput, 449 EXPECT_EQ(blink::WebMediaDeviceInfo::MediaDeviceKindAudioInput,
445 ms_impl_->last_devices()[1].kind()); 450 ms_impl_->last_devices()[1].kind());
446 EXPECT_FALSE(ms_impl_->last_devices()[1].label().isEmpty()); 451 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()));
447 } 473 }
448 474
449 } // namespace content 475 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_impl.cc ('k') | content/renderer/media/mock_media_stream_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698