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

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

Issue 2623443002: Fix getUserMedia so that failure is reported for invalid audio sources. (Closed)
Patch Set: Address comments 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 blink::WebString::fromUTF8("audio_track"), 289 blink::WebString::fromUTF8("audio_track"),
290 false /* remote */); 290 false /* remote */);
291 ProcessedLocalAudioSource* const audio_source = 291 ProcessedLocalAudioSource* const audio_source =
292 new ProcessedLocalAudioSource( 292 new ProcessedLocalAudioSource(
293 -1 /* consumer_render_frame_id is N/A for non-browser tests */, 293 -1 /* consumer_render_frame_id is N/A for non-browser tests */,
294 StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, "Mock device", 294 StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, "Mock device",
295 "mock_device_id", 295 "mock_device_id",
296 media::AudioParameters::kAudioCDSampleRate, 296 media::AudioParameters::kAudioCDSampleRate,
297 media::CHANNEL_LAYOUT_STEREO, 297 media::CHANNEL_LAYOUT_STEREO,
298 media::AudioParameters::kAudioCDSampleRate / 100), 298 media::AudioParameters::kAudioCDSampleRate / 100),
299 MockConstraintFactory().CreateWebMediaConstraints(),
300 base::Bind(&RTCPeerConnectionHandlerTest::OnAudioSourceStarted),
299 mock_dependency_factory_.get()); 301 mock_dependency_factory_.get());
300 audio_source->SetAllowInvalidRenderFrameIdForTesting(true); 302 audio_source->SetAllowInvalidRenderFrameIdForTesting(true);
301 audio_source->SetSourceConstraints(
302 MockConstraintFactory().CreateWebMediaConstraints());
303 blink_audio_source.setExtraData(audio_source); // Takes ownership. 303 blink_audio_source.setExtraData(audio_source); // Takes ownership.
304 304
305 blink::WebMediaStreamSource video_source; 305 blink::WebMediaStreamSource video_source;
306 video_source.initialize(blink::WebString::fromUTF8(video_track_label), 306 video_source.initialize(blink::WebString::fromUTF8(video_track_label),
307 blink::WebMediaStreamSource::TypeVideo, 307 blink::WebMediaStreamSource::TypeVideo,
308 blink::WebString::fromUTF8("video_track"), 308 blink::WebString::fromUTF8("video_track"),
309 false /* remote */); 309 false /* remote */);
310 MockMediaStreamVideoSource* native_video_source = 310 MockMediaStreamVideoSource* native_video_source =
311 new MockMediaStreamVideoSource(false); 311 new MockMediaStreamVideoSource(false);
312 video_source.setExtraData(native_video_source); 312 video_source.setExtraData(native_video_source);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 stream.audioTracks(audio_tracks); 359 stream.audioTracks(audio_tracks);
360 for (const auto& track : audio_tracks) 360 for (const auto& track : audio_tracks)
361 MediaStreamAudioTrack::From(track)->Stop(); 361 MediaStreamAudioTrack::From(track)->Stop();
362 362
363 blink::WebVector<blink::WebMediaStreamTrack> video_tracks; 363 blink::WebVector<blink::WebMediaStreamTrack> video_tracks;
364 stream.videoTracks(video_tracks); 364 stream.videoTracks(video_tracks);
365 for (const auto& track : video_tracks) 365 for (const auto& track : video_tracks)
366 MediaStreamVideoTrack::GetVideoTrack(track)->Stop(); 366 MediaStreamVideoTrack::GetVideoTrack(track)->Stop();
367 } 367 }
368 368
369 static void OnAudioSourceStarted(MediaStreamSource* source,
370 MediaStreamRequestResult result,
371 const blink::WebString& result_name) {}
372
369 base::MessageLoop message_loop_; 373 base::MessageLoop message_loop_;
370 std::unique_ptr<ChildProcess> child_process_; 374 std::unique_ptr<ChildProcess> child_process_;
371 std::unique_ptr<MockWebRTCPeerConnectionHandlerClient> mock_client_; 375 std::unique_ptr<MockWebRTCPeerConnectionHandlerClient> mock_client_;
372 std::unique_ptr<MockPeerConnectionDependencyFactory> mock_dependency_factory_; 376 std::unique_ptr<MockPeerConnectionDependencyFactory> mock_dependency_factory_;
373 std::unique_ptr<NiceMock<MockPeerConnectionTracker>> mock_tracker_; 377 std::unique_ptr<NiceMock<MockPeerConnectionTracker>> mock_tracker_;
374 std::unique_ptr<RTCPeerConnectionHandlerUnderTest> pc_handler_; 378 std::unique_ptr<RTCPeerConnectionHandlerUnderTest> pc_handler_;
375 MockAudioDeviceFactory mock_audio_device_factory_; 379 MockAudioDeviceFactory mock_audio_device_factory_;
376 380
377 // Weak reference to the mocked native peer connection implementation. 381 // Weak reference to the mocked native peer connection implementation.
378 MockPeerConnectionImpl* mock_peer_connection_; 382 MockPeerConnectionImpl* mock_peer_connection_;
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 testing::Ref(tracks[0]))); 1221 testing::Ref(tracks[0])));
1218 1222
1219 std::unique_ptr<blink::WebRTCDTMFSenderHandler> sender( 1223 std::unique_ptr<blink::WebRTCDTMFSenderHandler> sender(
1220 pc_handler_->createDTMFSender(tracks[0])); 1224 pc_handler_->createDTMFSender(tracks[0]));
1221 EXPECT_TRUE(sender.get()); 1225 EXPECT_TRUE(sender.get());
1222 1226
1223 StopAllTracks(local_stream); 1227 StopAllTracks(local_stream);
1224 } 1228 }
1225 1229
1226 } // namespace content 1230 } // 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