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

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

Issue 2622073003: Fix getUserMedia so that failure is reported for invalid audio sources. (Closed)
Patch Set: Switch to std::vector and std::unique_ptr Created 3 years, 11 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/rtc_peer_connection_handler.h" 5 #include "content/renderer/media/rtc_peer_connection_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 blink::WebString::fromUTF8("audio_track"), 294 blink::WebString::fromUTF8("audio_track"),
295 false /* remote */); 295 false /* remote */);
296 ProcessedLocalAudioSource* const audio_source = 296 ProcessedLocalAudioSource* const audio_source =
297 new ProcessedLocalAudioSource( 297 new ProcessedLocalAudioSource(
298 -1 /* consumer_render_frame_id is N/A for non-browser tests */, 298 -1 /* consumer_render_frame_id is N/A for non-browser tests */,
299 StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, "Mock device", 299 StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, "Mock device",
300 "mock_device_id", 300 "mock_device_id",
301 media::AudioParameters::kAudioCDSampleRate, 301 media::AudioParameters::kAudioCDSampleRate,
302 media::CHANNEL_LAYOUT_STEREO, 302 media::CHANNEL_LAYOUT_STEREO,
303 media::AudioParameters::kAudioCDSampleRate / 100), 303 media::AudioParameters::kAudioCDSampleRate / 100),
304 MockConstraintFactory().CreateWebMediaConstraints(),
305 base::Bind(&RTCPeerConnectionHandlerTest::OnAudioSourceStarted),
304 mock_dependency_factory_.get()); 306 mock_dependency_factory_.get());
305 audio_source->SetAllowInvalidRenderFrameIdForTesting(true); 307 audio_source->SetAllowInvalidRenderFrameIdForTesting(true);
306 audio_source->SetSourceConstraints(
307 MockConstraintFactory().CreateWebMediaConstraints());
308 blink_audio_source.setExtraData(audio_source); // Takes ownership. 308 blink_audio_source.setExtraData(audio_source); // Takes ownership.
309 309
310 blink::WebMediaStreamSource video_source; 310 blink::WebMediaStreamSource video_source;
311 video_source.initialize(blink::WebString::fromUTF8(video_track_label), 311 video_source.initialize(blink::WebString::fromUTF8(video_track_label),
312 blink::WebMediaStreamSource::TypeVideo, 312 blink::WebMediaStreamSource::TypeVideo,
313 blink::WebString::fromUTF8("video_track"), 313 blink::WebString::fromUTF8("video_track"),
314 false /* remote */); 314 false /* remote */);
315 MockMediaStreamVideoSource* native_video_source = 315 MockMediaStreamVideoSource* native_video_source =
316 new MockMediaStreamVideoSource(false); 316 new MockMediaStreamVideoSource(false);
317 video_source.setExtraData(native_video_source); 317 video_source.setExtraData(native_video_source);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 stream.audioTracks(audio_tracks); 364 stream.audioTracks(audio_tracks);
365 for (const auto& track : audio_tracks) 365 for (const auto& track : audio_tracks)
366 MediaStreamAudioTrack::From(track)->Stop(); 366 MediaStreamAudioTrack::From(track)->Stop();
367 367
368 blink::WebVector<blink::WebMediaStreamTrack> video_tracks; 368 blink::WebVector<blink::WebMediaStreamTrack> video_tracks;
369 stream.videoTracks(video_tracks); 369 stream.videoTracks(video_tracks);
370 for (const auto& track : video_tracks) 370 for (const auto& track : video_tracks)
371 MediaStreamVideoTrack::GetVideoTrack(track)->Stop(); 371 MediaStreamVideoTrack::GetVideoTrack(track)->Stop();
372 } 372 }
373 373
374 static void OnAudioSourceStarted(MediaStreamSource* source,
375 MediaStreamRequestResult result,
376 const blink::WebString& result_name) {}
377
374 base::MessageLoop message_loop_; 378 base::MessageLoop message_loop_;
375 std::unique_ptr<ChildProcess> child_process_; 379 std::unique_ptr<ChildProcess> child_process_;
376 std::unique_ptr<MockWebRTCPeerConnectionHandlerClient> mock_client_; 380 std::unique_ptr<MockWebRTCPeerConnectionHandlerClient> mock_client_;
377 std::unique_ptr<MockPeerConnectionDependencyFactory> mock_dependency_factory_; 381 std::unique_ptr<MockPeerConnectionDependencyFactory> mock_dependency_factory_;
378 std::unique_ptr<NiceMock<MockPeerConnectionTracker>> mock_tracker_; 382 std::unique_ptr<NiceMock<MockPeerConnectionTracker>> mock_tracker_;
379 std::unique_ptr<RTCPeerConnectionHandlerUnderTest> pc_handler_; 383 std::unique_ptr<RTCPeerConnectionHandlerUnderTest> pc_handler_;
380 MockAudioDeviceFactory mock_audio_device_factory_; 384 MockAudioDeviceFactory mock_audio_device_factory_;
381 385
382 // Weak reference to the mocked native peer connection implementation. 386 // Weak reference to the mocked native peer connection implementation.
383 MockPeerConnectionImpl* mock_peer_connection_; 387 MockPeerConnectionImpl* mock_peer_connection_;
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 testing::Ref(tracks[0]))); 1286 testing::Ref(tracks[0])));
1283 1287
1284 std::unique_ptr<blink::WebRTCDTMFSenderHandler> sender( 1288 std::unique_ptr<blink::WebRTCDTMFSenderHandler> sender(
1285 pc_handler_->createDTMFSender(tracks[0])); 1289 pc_handler_->createDTMFSender(tracks[0]));
1286 EXPECT_TRUE(sender.get()); 1290 EXPECT_TRUE(sender.get());
1287 1291
1288 StopAllTracks(local_stream); 1292 StopAllTracks(local_stream);
1289 } 1293 }
1290 1294
1291 } // namespace content 1295 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/local_media_stream_audio_source.cc ('k') | content/renderer/media/user_media_client_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698