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

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

Issue 1721273002: MediaStream audio object graph untangling and clean-ups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests broken by recent MSAudioTrack::Stop() reworking. Created 4 years, 9 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
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 "content/renderer/media/user_media_client_impl.h" 5 #include "content/renderer/media/user_media_client_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "content/child/child_process.h" 13 #include "content/child/child_process.h"
14 #include "content/renderer/media/media_stream.h" 14 #include "content/renderer/media/media_stream.h"
15 #include "content/renderer/media/media_stream_audio_source.h"
15 #include "content/renderer/media/media_stream_track.h" 16 #include "content/renderer/media/media_stream_track.h"
16 #include "content/renderer/media/mock_media_stream_dispatcher.h" 17 #include "content/renderer/media/mock_media_stream_dispatcher.h"
17 #include "content/renderer/media/mock_media_stream_video_source.h" 18 #include "content/renderer/media/mock_media_stream_video_source.h"
18 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory. h" 19 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory. h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 #include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h" 21 #include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h"
21 #include "third_party/WebKit/public/platform/WebMediaStream.h" 22 #include "third_party/WebKit/public/platform/WebMediaStream.h"
22 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 23 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
23 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 24 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
24 #include "third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h " 25 #include "third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h "
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 EXPECT_EQ(desc1_video_tracks[0].source().getExtraData(), 278 EXPECT_EQ(desc1_video_tracks[0].source().getExtraData(),
278 desc2_video_tracks[0].source().getExtraData()); 279 desc2_video_tracks[0].source().getExtraData());
279 280
280 blink::WebVector<blink::WebMediaStreamTrack> desc1_audio_tracks; 281 blink::WebVector<blink::WebMediaStreamTrack> desc1_audio_tracks;
281 desc1.audioTracks(desc1_audio_tracks); 282 desc1.audioTracks(desc1_audio_tracks);
282 blink::WebVector<blink::WebMediaStreamTrack> desc2_audio_tracks; 283 blink::WebVector<blink::WebMediaStreamTrack> desc2_audio_tracks;
283 desc2.audioTracks(desc2_audio_tracks); 284 desc2.audioTracks(desc2_audio_tracks);
284 EXPECT_EQ(desc1_audio_tracks[0].source().id(), 285 EXPECT_EQ(desc1_audio_tracks[0].source().id(),
285 desc2_audio_tracks[0].source().id()); 286 desc2_audio_tracks[0].source().id());
286 287
287 EXPECT_EQ(desc1_audio_tracks[0].source().getExtraData(), 288 EXPECT_EQ(MediaStreamAudioSource::From(desc1_audio_tracks[0].source()),
288 desc2_audio_tracks[0].source().getExtraData()); 289 MediaStreamAudioSource::From(desc2_audio_tracks[0].source()));
289 } 290 }
290 291
291 // Test that the same source object is not used if two MediaStreams are 292 // Test that the same source object is not used if two MediaStreams are
292 // generated using different sources. 293 // generated using different sources.
293 TEST_F(UserMediaClientImplTest, GenerateTwoMediaStreamsWithDifferentSources) { 294 TEST_F(UserMediaClientImplTest, GenerateTwoMediaStreamsWithDifferentSources) {
294 blink::WebMediaStream desc1 = RequestLocalMediaStream(); 295 blink::WebMediaStream desc1 = RequestLocalMediaStream();
295 // Make sure another device is selected (another |session_id|) in the next 296 // Make sure another device is selected (another |session_id|) in the next
296 // gUM request. 297 // gUM request.
297 ms_dispatcher_->IncrementSessionId(); 298 ms_dispatcher_->IncrementSessionId();
298 blink::WebMediaStream desc2 = RequestLocalMediaStream(); 299 blink::WebMediaStream desc2 = RequestLocalMediaStream();
299 300
300 blink::WebVector<blink::WebMediaStreamTrack> desc1_video_tracks; 301 blink::WebVector<blink::WebMediaStreamTrack> desc1_video_tracks;
301 desc1.videoTracks(desc1_video_tracks); 302 desc1.videoTracks(desc1_video_tracks);
302 blink::WebVector<blink::WebMediaStreamTrack> desc2_video_tracks; 303 blink::WebVector<blink::WebMediaStreamTrack> desc2_video_tracks;
303 desc2.videoTracks(desc2_video_tracks); 304 desc2.videoTracks(desc2_video_tracks);
304 EXPECT_NE(desc1_video_tracks[0].source().id(), 305 EXPECT_NE(desc1_video_tracks[0].source().id(),
305 desc2_video_tracks[0].source().id()); 306 desc2_video_tracks[0].source().id());
306 307
307 EXPECT_NE(desc1_video_tracks[0].source().getExtraData(), 308 EXPECT_NE(desc1_video_tracks[0].source().getExtraData(),
308 desc2_video_tracks[0].source().getExtraData()); 309 desc2_video_tracks[0].source().getExtraData());
309 310
310 blink::WebVector<blink::WebMediaStreamTrack> desc1_audio_tracks; 311 blink::WebVector<blink::WebMediaStreamTrack> desc1_audio_tracks;
311 desc1.audioTracks(desc1_audio_tracks); 312 desc1.audioTracks(desc1_audio_tracks);
312 blink::WebVector<blink::WebMediaStreamTrack> desc2_audio_tracks; 313 blink::WebVector<blink::WebMediaStreamTrack> desc2_audio_tracks;
313 desc2.audioTracks(desc2_audio_tracks); 314 desc2.audioTracks(desc2_audio_tracks);
314 EXPECT_NE(desc1_audio_tracks[0].source().id(), 315 EXPECT_NE(desc1_audio_tracks[0].source().id(),
315 desc2_audio_tracks[0].source().id()); 316 desc2_audio_tracks[0].source().id());
316 317
317 EXPECT_NE(desc1_audio_tracks[0].source().getExtraData(), 318 EXPECT_NE(MediaStreamAudioSource::From(desc1_audio_tracks[0].source()),
318 desc2_audio_tracks[0].source().getExtraData()); 319 MediaStreamAudioSource::From(desc2_audio_tracks[0].source()));
319 } 320 }
320 321
321 TEST_F(UserMediaClientImplTest, StopLocalTracks) { 322 TEST_F(UserMediaClientImplTest, StopLocalTracks) {
322 // Generate a stream with both audio and video. 323 // Generate a stream with both audio and video.
323 blink::WebMediaStream mixed_desc = RequestLocalMediaStream(); 324 blink::WebMediaStream mixed_desc = RequestLocalMediaStream();
324 325
325 blink::WebVector<blink::WebMediaStreamTrack> audio_tracks; 326 blink::WebVector<blink::WebMediaStreamTrack> audio_tracks;
326 mixed_desc.audioTracks(audio_tracks); 327 mixed_desc.audioTracks(audio_tracks);
327 MediaStreamTrack* audio_track = MediaStreamTrack::GetTrack(audio_tracks[0]); 328 MediaStreamTrack* audio_track = MediaStreamTrack::GetTrack(audio_tracks[0]);
328 audio_track->Stop(); 329 audio_track->Stop();
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 570
570 // Video input device environment facing. 571 // Video input device environment facing.
571 source = &used_media_impl_->last_sources()[3]; 572 source = &used_media_impl_->last_sources()[3];
572 EXPECT_FALSE(source->id().isEmpty()); 573 EXPECT_FALSE(source->id().isEmpty());
573 EXPECT_EQ(blink::WebSourceInfo::SourceKindVideo, source->kind()); 574 EXPECT_EQ(blink::WebSourceInfo::SourceKindVideo, source->kind());
574 EXPECT_FALSE(source->label().isEmpty()); 575 EXPECT_FALSE(source->label().isEmpty());
575 EXPECT_EQ(blink::WebSourceInfo::VideoFacingModeEnvironment, source->facing()); 576 EXPECT_EQ(blink::WebSourceInfo::VideoFacingModeEnvironment, source->facing());
576 } 577 }
577 578
578 } // namespace content 579 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698