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

Side by Side Diff: webrtc/api/peerconnectioninterface_unittest.cc

Issue 2600813002: Revert of Adding error output param to SetConfiguration, using new RTCError type. (Closed)
Patch Set: Created 3 years, 12 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
« no previous file with comments | « webrtc/api/peerconnectioninterface.h ('k') | webrtc/api/peerconnectionproxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 using webrtc::MediaStreamInterface; 314 using webrtc::MediaStreamInterface;
315 using webrtc::MediaStreamTrackInterface; 315 using webrtc::MediaStreamTrackInterface;
316 using webrtc::MockCreateSessionDescriptionObserver; 316 using webrtc::MockCreateSessionDescriptionObserver;
317 using webrtc::MockDataChannelObserver; 317 using webrtc::MockDataChannelObserver;
318 using webrtc::MockSetSessionDescriptionObserver; 318 using webrtc::MockSetSessionDescriptionObserver;
319 using webrtc::MockStatsObserver; 319 using webrtc::MockStatsObserver;
320 using webrtc::NotifierInterface; 320 using webrtc::NotifierInterface;
321 using webrtc::ObserverInterface; 321 using webrtc::ObserverInterface;
322 using webrtc::PeerConnectionInterface; 322 using webrtc::PeerConnectionInterface;
323 using webrtc::PeerConnectionObserver; 323 using webrtc::PeerConnectionObserver;
324 using webrtc::RTCError;
325 using webrtc::RTCErrorType;
326 using webrtc::RtpReceiverInterface; 324 using webrtc::RtpReceiverInterface;
327 using webrtc::RtpSenderInterface; 325 using webrtc::RtpSenderInterface;
328 using webrtc::SdpParseError; 326 using webrtc::SdpParseError;
329 using webrtc::SessionDescriptionInterface; 327 using webrtc::SessionDescriptionInterface;
330 using webrtc::StreamCollection; 328 using webrtc::StreamCollection;
331 using webrtc::StreamCollectionInterface; 329 using webrtc::StreamCollectionInterface;
332 using webrtc::VideoTrackSourceInterface; 330 using webrtc::VideoTrackSourceInterface;
333 using webrtc::VideoTrack; 331 using webrtc::VideoTrack;
334 using webrtc::VideoTrackInterface; 332 using webrtc::VideoTrackInterface;
335 333
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 ASSERT_TRUE(pc_factory_); 687 ASSERT_TRUE(pc_factory_);
690 pc_factory_for_test_ = 688 pc_factory_for_test_ =
691 new rtc::RefCountedObject<PeerConnectionFactoryForTest>(); 689 new rtc::RefCountedObject<PeerConnectionFactoryForTest>();
692 pc_factory_for_test_->Initialize(); 690 pc_factory_for_test_->Initialize();
693 } 691 }
694 692
695 void CreatePeerConnection() { 693 void CreatePeerConnection() {
696 CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(), nullptr); 694 CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(), nullptr);
697 } 695 }
698 696
699 // DTLS does not work in a loopback call, so is disabled for most of the
700 // tests in this file.
701 void CreatePeerConnectionWithoutDtls() {
702 FakeConstraints no_dtls_constraints;
703 no_dtls_constraints.AddMandatory(
704 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false);
705
706 CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(),
707 &no_dtls_constraints);
708 }
709
710 void CreatePeerConnection(webrtc::MediaConstraintsInterface* constraints) { 697 void CreatePeerConnection(webrtc::MediaConstraintsInterface* constraints) {
711 CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(), 698 CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(),
712 constraints); 699 constraints);
713 } 700 }
714 701
715 void CreatePeerConnectionWithIceTransportsType( 702 void CreatePeerConnectionWithIceTransportsType(
716 PeerConnectionInterface::IceTransportsType type) { 703 PeerConnectionInterface::IceTransportsType type) {
717 PeerConnectionInterface::RTCConfiguration config; 704 PeerConnectionInterface::RTCConfiguration config;
718 config.type = type; 705 config.type = type;
719 return CreatePeerConnection(config, nullptr); 706 return CreatePeerConnection(config, nullptr);
720 } 707 }
721 708
722 void CreatePeerConnectionWithIceServer(const std::string& uri, 709 void CreatePeerConnectionWithIceServer(const std::string& uri,
723 const std::string& password) { 710 const std::string& password) {
724 PeerConnectionInterface::RTCConfiguration config; 711 PeerConnectionInterface::RTCConfiguration config;
725 PeerConnectionInterface::IceServer server; 712 PeerConnectionInterface::IceServer server;
726 server.uri = uri; 713 server.uri = uri;
727 server.password = password; 714 server.password = password;
728 config.servers.push_back(server); 715 config.servers.push_back(server);
729 CreatePeerConnection(config, nullptr); 716 CreatePeerConnection(config, nullptr);
730 } 717 }
731 718
732 void CreatePeerConnection(PeerConnectionInterface::RTCConfiguration config, 719 void CreatePeerConnection(PeerConnectionInterface::RTCConfiguration config,
733 webrtc::MediaConstraintsInterface* constraints) { 720 webrtc::MediaConstraintsInterface* constraints) {
734 std::unique_ptr<cricket::FakePortAllocator> port_allocator( 721 std::unique_ptr<cricket::FakePortAllocator> port_allocator(
735 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr)); 722 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr));
736 port_allocator_ = port_allocator.get(); 723 port_allocator_ = port_allocator.get();
737 724
725 // DTLS does not work in a loopback call, so is disabled for most of the
726 // tests in this file. We only create a FakeIdentityService if the test
727 // explicitly sets the constraint.
728 FakeConstraints default_constraints;
729 if (!constraints) {
730 constraints = &default_constraints;
731
732 default_constraints.AddMandatory(
733 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false);
734 }
735
738 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator; 736 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator;
739 bool dtls; 737 bool dtls;
740 if (FindConstraint(constraints, 738 if (FindConstraint(constraints,
741 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 739 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
742 &dtls, 740 &dtls,
743 nullptr) && dtls) { 741 nullptr) && dtls) {
744 cert_generator.reset(new FakeRTCCertificateGenerator()); 742 cert_generator.reset(new FakeRTCCertificateGenerator());
745 } 743 }
746 pc_ = pc_factory_->CreatePeerConnection( 744 pc_ = pc_factory_->CreatePeerConnection(
747 config, constraints, std::move(port_allocator), 745 config, constraints, std::move(port_allocator),
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 rtc::scoped_refptr<MockStatsObserver> observer( 891 rtc::scoped_refptr<MockStatsObserver> observer(
894 new rtc::RefCountedObject<MockStatsObserver>()); 892 new rtc::RefCountedObject<MockStatsObserver>());
895 if (!pc_->GetStats( 893 if (!pc_->GetStats(
896 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard)) 894 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard))
897 return false; 895 return false;
898 EXPECT_TRUE_WAIT(observer->called(), kTimeout); 896 EXPECT_TRUE_WAIT(observer->called(), kTimeout);
899 return observer->called(); 897 return observer->called();
900 } 898 }
901 899
902 void InitiateCall() { 900 void InitiateCall() {
903 CreatePeerConnectionWithoutDtls(); 901 CreatePeerConnection();
904 // Create a local stream with audio&video tracks. 902 // Create a local stream with audio&video tracks.
905 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); 903 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label");
906 CreateOfferReceiveAnswer(); 904 CreateOfferReceiveAnswer();
907 } 905 }
908 906
909 // Verify that RTP Header extensions has been negotiated for audio and video. 907 // Verify that RTP Header extensions has been negotiated for audio and video.
910 void VerifyRemoteRtpHeaderExtensions() { 908 void VerifyRemoteRtpHeaderExtensions() {
911 const cricket::MediaContentDescription* desc = 909 const cricket::MediaContentDescription* desc =
912 cricket::GetFirstAudioContentDescription( 910 cricket::GetFirstAudioContentDescription(
913 pc_->remote_description()->description()); 911 pc_->remote_description()->description());
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 1098
1101 void AddVideoTrack(const std::string& track_id, 1099 void AddVideoTrack(const std::string& track_id,
1102 MediaStreamInterface* stream) { 1100 MediaStreamInterface* stream) {
1103 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( 1101 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track(
1104 webrtc::VideoTrack::Create(track_id, 1102 webrtc::VideoTrack::Create(track_id,
1105 webrtc::FakeVideoTrackSource::Create())); 1103 webrtc::FakeVideoTrackSource::Create()));
1106 ASSERT_TRUE(stream->AddTrack(video_track)); 1104 ASSERT_TRUE(stream->AddTrack(video_track));
1107 } 1105 }
1108 1106
1109 std::unique_ptr<SessionDescriptionInterface> CreateOfferWithOneAudioStream() { 1107 std::unique_ptr<SessionDescriptionInterface> CreateOfferWithOneAudioStream() {
1110 CreatePeerConnectionWithoutDtls(); 1108 CreatePeerConnection();
1111 AddVoiceStream(kStreamLabel1); 1109 AddVoiceStream(kStreamLabel1);
1112 std::unique_ptr<SessionDescriptionInterface> offer; 1110 std::unique_ptr<SessionDescriptionInterface> offer;
1113 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); 1111 EXPECT_TRUE(DoCreateOffer(&offer, nullptr));
1114 return offer; 1112 return offer;
1115 } 1113 }
1116 1114
1117 std::unique_ptr<SessionDescriptionInterface> 1115 std::unique_ptr<SessionDescriptionInterface>
1118 CreateAnswerWithOneAudioStream() { 1116 CreateAnswerWithOneAudioStream() {
1119 std::unique_ptr<SessionDescriptionInterface> offer = 1117 std::unique_ptr<SessionDescriptionInterface> offer =
1120 CreateOfferWithOneAudioStream(); 1118 CreateOfferWithOneAudioStream();
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 PeerConnectionInterface::RTCConfiguration config; 1274 PeerConnectionInterface::RTCConfiguration config;
1277 config.type = PeerConnectionInterface::kRelay; 1275 config.type = PeerConnectionInterface::kRelay;
1278 EXPECT_TRUE(pc_->SetConfiguration(config)); 1276 EXPECT_TRUE(pc_->SetConfiguration(config));
1279 1277
1280 PeerConnectionInterface::RTCConfiguration returned_config = 1278 PeerConnectionInterface::RTCConfiguration returned_config =
1281 pc_->GetConfiguration(); 1279 pc_->GetConfiguration();
1282 EXPECT_EQ(PeerConnectionInterface::kRelay, returned_config.type); 1280 EXPECT_EQ(PeerConnectionInterface::kRelay, returned_config.type);
1283 } 1281 }
1284 1282
1285 TEST_F(PeerConnectionInterfaceTest, AddStreams) { 1283 TEST_F(PeerConnectionInterfaceTest, AddStreams) {
1286 CreatePeerConnectionWithoutDtls(); 1284 CreatePeerConnection();
1287 AddVideoStream(kStreamLabel1); 1285 AddVideoStream(kStreamLabel1);
1288 AddVoiceStream(kStreamLabel2); 1286 AddVoiceStream(kStreamLabel2);
1289 ASSERT_EQ(2u, pc_->local_streams()->count()); 1287 ASSERT_EQ(2u, pc_->local_streams()->count());
1290 1288
1291 // Test we can add multiple local streams to one peerconnection. 1289 // Test we can add multiple local streams to one peerconnection.
1292 rtc::scoped_refptr<MediaStreamInterface> stream( 1290 rtc::scoped_refptr<MediaStreamInterface> stream(
1293 pc_factory_->CreateLocalMediaStream(kStreamLabel3)); 1291 pc_factory_->CreateLocalMediaStream(kStreamLabel3));
1294 rtc::scoped_refptr<AudioTrackInterface> audio_track( 1292 rtc::scoped_refptr<AudioTrackInterface> audio_track(
1295 pc_factory_->CreateAudioTrack(kStreamLabel3, 1293 pc_factory_->CreateAudioTrack(kStreamLabel3,
1296 static_cast<AudioSourceInterface*>(NULL))); 1294 static_cast<AudioSourceInterface*>(NULL)));
1297 stream->AddTrack(audio_track.get()); 1295 stream->AddTrack(audio_track.get());
1298 EXPECT_TRUE(pc_->AddStream(stream)); 1296 EXPECT_TRUE(pc_->AddStream(stream));
1299 EXPECT_EQ(3u, pc_->local_streams()->count()); 1297 EXPECT_EQ(3u, pc_->local_streams()->count());
1300 1298
1301 // Remove the third stream. 1299 // Remove the third stream.
1302 pc_->RemoveStream(pc_->local_streams()->at(2)); 1300 pc_->RemoveStream(pc_->local_streams()->at(2));
1303 EXPECT_EQ(2u, pc_->local_streams()->count()); 1301 EXPECT_EQ(2u, pc_->local_streams()->count());
1304 1302
1305 // Remove the second stream. 1303 // Remove the second stream.
1306 pc_->RemoveStream(pc_->local_streams()->at(1)); 1304 pc_->RemoveStream(pc_->local_streams()->at(1));
1307 EXPECT_EQ(1u, pc_->local_streams()->count()); 1305 EXPECT_EQ(1u, pc_->local_streams()->count());
1308 1306
1309 // Remove the first stream. 1307 // Remove the first stream.
1310 pc_->RemoveStream(pc_->local_streams()->at(0)); 1308 pc_->RemoveStream(pc_->local_streams()->at(0));
1311 EXPECT_EQ(0u, pc_->local_streams()->count()); 1309 EXPECT_EQ(0u, pc_->local_streams()->count());
1312 } 1310 }
1313 1311
1314 // Test that the created offer includes streams we added. 1312 // Test that the created offer includes streams we added.
1315 TEST_F(PeerConnectionInterfaceTest, AddedStreamsPresentInOffer) { 1313 TEST_F(PeerConnectionInterfaceTest, AddedStreamsPresentInOffer) {
1316 CreatePeerConnectionWithoutDtls(); 1314 CreatePeerConnection();
1317 AddAudioVideoStream(kStreamLabel1, "audio_track", "video_track"); 1315 AddAudioVideoStream(kStreamLabel1, "audio_track", "video_track");
1318 std::unique_ptr<SessionDescriptionInterface> offer; 1316 std::unique_ptr<SessionDescriptionInterface> offer;
1319 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); 1317 ASSERT_TRUE(DoCreateOffer(&offer, nullptr));
1320 1318
1321 const cricket::ContentInfo* audio_content = 1319 const cricket::ContentInfo* audio_content =
1322 cricket::GetFirstAudioContent(offer->description()); 1320 cricket::GetFirstAudioContent(offer->description());
1323 const cricket::AudioContentDescription* audio_desc = 1321 const cricket::AudioContentDescription* audio_desc =
1324 static_cast<const cricket::AudioContentDescription*>( 1322 static_cast<const cricket::AudioContentDescription*>(
1325 audio_content->description); 1323 audio_content->description);
1326 EXPECT_TRUE( 1324 EXPECT_TRUE(
(...skipping 23 matching lines...) Expand all
1350 video_content = cricket::GetFirstVideoContent(offer->description()); 1348 video_content = cricket::GetFirstVideoContent(offer->description());
1351 video_desc = static_cast<const cricket::VideoContentDescription*>( 1349 video_desc = static_cast<const cricket::VideoContentDescription*>(
1352 video_content->description); 1350 video_content->description);
1353 EXPECT_TRUE( 1351 EXPECT_TRUE(
1354 ContainsTrack(video_desc->streams(), kStreamLabel1, "video_track")); 1352 ContainsTrack(video_desc->streams(), kStreamLabel1, "video_track"));
1355 EXPECT_TRUE( 1353 EXPECT_TRUE(
1356 ContainsTrack(video_desc->streams(), kStreamLabel2, "video_track2")); 1354 ContainsTrack(video_desc->streams(), kStreamLabel2, "video_track2"));
1357 } 1355 }
1358 1356
1359 TEST_F(PeerConnectionInterfaceTest, RemoveStream) { 1357 TEST_F(PeerConnectionInterfaceTest, RemoveStream) {
1360 CreatePeerConnectionWithoutDtls(); 1358 CreatePeerConnection();
1361 AddVideoStream(kStreamLabel1); 1359 AddVideoStream(kStreamLabel1);
1362 ASSERT_EQ(1u, pc_->local_streams()->count()); 1360 ASSERT_EQ(1u, pc_->local_streams()->count());
1363 pc_->RemoveStream(pc_->local_streams()->at(0)); 1361 pc_->RemoveStream(pc_->local_streams()->at(0));
1364 EXPECT_EQ(0u, pc_->local_streams()->count()); 1362 EXPECT_EQ(0u, pc_->local_streams()->count());
1365 } 1363 }
1366 1364
1367 // Test for AddTrack and RemoveTrack methods. 1365 // Test for AddTrack and RemoveTrack methods.
1368 // Tests that the created offer includes tracks we added, 1366 // Tests that the created offer includes tracks we added,
1369 // and that the RtpSenders are created correctly. 1367 // and that the RtpSenders are created correctly.
1370 // Also tests that RemoveTrack removes the tracks from subsequent offers. 1368 // Also tests that RemoveTrack removes the tracks from subsequent offers.
1371 TEST_F(PeerConnectionInterfaceTest, AddTrackRemoveTrack) { 1369 TEST_F(PeerConnectionInterfaceTest, AddTrackRemoveTrack) {
1372 CreatePeerConnectionWithoutDtls(); 1370 CreatePeerConnection();
1373 // Create a dummy stream, so tracks share a stream label. 1371 // Create a dummy stream, so tracks share a stream label.
1374 rtc::scoped_refptr<MediaStreamInterface> stream( 1372 rtc::scoped_refptr<MediaStreamInterface> stream(
1375 pc_factory_->CreateLocalMediaStream(kStreamLabel1)); 1373 pc_factory_->CreateLocalMediaStream(kStreamLabel1));
1376 std::vector<MediaStreamInterface*> stream_list; 1374 std::vector<MediaStreamInterface*> stream_list;
1377 stream_list.push_back(stream.get()); 1375 stream_list.push_back(stream.get());
1378 rtc::scoped_refptr<AudioTrackInterface> audio_track( 1376 rtc::scoped_refptr<AudioTrackInterface> audio_track(
1379 pc_factory_->CreateAudioTrack("audio_track", nullptr)); 1377 pc_factory_->CreateAudioTrack("audio_track", nullptr));
1380 rtc::scoped_refptr<VideoTrackInterface> video_track( 1378 rtc::scoped_refptr<VideoTrackInterface> video_track(
1381 pc_factory_->CreateVideoTrack( 1379 pc_factory_->CreateVideoTrack(
1382 "video_track", 1380 "video_track",
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 1435
1438 // Calling RemoveTrack on a sender no longer attached to a PeerConnection 1436 // Calling RemoveTrack on a sender no longer attached to a PeerConnection
1439 // should return false. 1437 // should return false.
1440 EXPECT_FALSE(pc_->RemoveTrack(audio_sender)); 1438 EXPECT_FALSE(pc_->RemoveTrack(audio_sender));
1441 EXPECT_FALSE(pc_->RemoveTrack(video_sender)); 1439 EXPECT_FALSE(pc_->RemoveTrack(video_sender));
1442 } 1440 }
1443 1441
1444 // Test creating senders without a stream specified, 1442 // Test creating senders without a stream specified,
1445 // expecting a random stream ID to be generated. 1443 // expecting a random stream ID to be generated.
1446 TEST_F(PeerConnectionInterfaceTest, AddTrackWithoutStream) { 1444 TEST_F(PeerConnectionInterfaceTest, AddTrackWithoutStream) {
1447 CreatePeerConnectionWithoutDtls(); 1445 CreatePeerConnection();
1448 // Create a dummy stream, so tracks share a stream label. 1446 // Create a dummy stream, so tracks share a stream label.
1449 rtc::scoped_refptr<AudioTrackInterface> audio_track( 1447 rtc::scoped_refptr<AudioTrackInterface> audio_track(
1450 pc_factory_->CreateAudioTrack("audio_track", nullptr)); 1448 pc_factory_->CreateAudioTrack("audio_track", nullptr));
1451 rtc::scoped_refptr<VideoTrackInterface> video_track( 1449 rtc::scoped_refptr<VideoTrackInterface> video_track(
1452 pc_factory_->CreateVideoTrack( 1450 pc_factory_->CreateVideoTrack(
1453 "video_track", 1451 "video_track",
1454 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer()))); 1452 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer())));
1455 auto audio_sender = 1453 auto audio_sender =
1456 pc_->AddTrack(audio_track, std::vector<MediaStreamInterface*>()); 1454 pc_->AddTrack(audio_track, std::vector<MediaStreamInterface*>());
1457 auto video_sender = 1455 auto video_sender =
1458 pc_->AddTrack(video_track, std::vector<MediaStreamInterface*>()); 1456 pc_->AddTrack(video_track, std::vector<MediaStreamInterface*>());
1459 EXPECT_EQ("audio_track", audio_sender->id()); 1457 EXPECT_EQ("audio_track", audio_sender->id());
1460 EXPECT_EQ(audio_track, audio_sender->track()); 1458 EXPECT_EQ(audio_track, audio_sender->track());
1461 EXPECT_EQ("video_track", video_sender->id()); 1459 EXPECT_EQ("video_track", video_sender->id());
1462 EXPECT_EQ(video_track, video_sender->track()); 1460 EXPECT_EQ(video_track, video_sender->track());
1463 // If the ID is truly a random GUID, it should be infinitely unlikely they 1461 // If the ID is truly a random GUID, it should be infinitely unlikely they
1464 // will be the same. 1462 // will be the same.
1465 EXPECT_NE(video_sender->stream_ids(), audio_sender->stream_ids()); 1463 EXPECT_NE(video_sender->stream_ids(), audio_sender->stream_ids());
1466 } 1464 }
1467 1465
1468 TEST_F(PeerConnectionInterfaceTest, CreateOfferReceiveAnswer) { 1466 TEST_F(PeerConnectionInterfaceTest, CreateOfferReceiveAnswer) {
1469 InitiateCall(); 1467 InitiateCall();
1470 WaitAndVerifyOnAddStream(kStreamLabel1); 1468 WaitAndVerifyOnAddStream(kStreamLabel1);
1471 VerifyRemoteRtpHeaderExtensions(); 1469 VerifyRemoteRtpHeaderExtensions();
1472 } 1470 }
1473 1471
1474 TEST_F(PeerConnectionInterfaceTest, CreateOfferReceivePrAnswerAndAnswer) { 1472 TEST_F(PeerConnectionInterfaceTest, CreateOfferReceivePrAnswerAndAnswer) {
1475 CreatePeerConnectionWithoutDtls(); 1473 CreatePeerConnection();
1476 AddVideoStream(kStreamLabel1); 1474 AddVideoStream(kStreamLabel1);
1477 CreateOfferAsLocalDescription(); 1475 CreateOfferAsLocalDescription();
1478 std::string offer; 1476 std::string offer;
1479 EXPECT_TRUE(pc_->local_description()->ToString(&offer)); 1477 EXPECT_TRUE(pc_->local_description()->ToString(&offer));
1480 CreatePrAnswerAndAnswerAsRemoteDescription(offer); 1478 CreatePrAnswerAndAnswerAsRemoteDescription(offer);
1481 WaitAndVerifyOnAddStream(kStreamLabel1); 1479 WaitAndVerifyOnAddStream(kStreamLabel1);
1482 } 1480 }
1483 1481
1484 TEST_F(PeerConnectionInterfaceTest, ReceiveOfferCreateAnswer) { 1482 TEST_F(PeerConnectionInterfaceTest, ReceiveOfferCreateAnswer) {
1485 CreatePeerConnectionWithoutDtls(); 1483 CreatePeerConnection();
1486 AddVideoStream(kStreamLabel1); 1484 AddVideoStream(kStreamLabel1);
1487 1485
1488 CreateOfferAsRemoteDescription(); 1486 CreateOfferAsRemoteDescription();
1489 CreateAnswerAsLocalDescription(); 1487 CreateAnswerAsLocalDescription();
1490 1488
1491 WaitAndVerifyOnAddStream(kStreamLabel1); 1489 WaitAndVerifyOnAddStream(kStreamLabel1);
1492 } 1490 }
1493 1491
1494 TEST_F(PeerConnectionInterfaceTest, ReceiveOfferCreatePrAnswerAndAnswer) { 1492 TEST_F(PeerConnectionInterfaceTest, ReceiveOfferCreatePrAnswerAndAnswer) {
1495 CreatePeerConnectionWithoutDtls(); 1493 CreatePeerConnection();
1496 AddVideoStream(kStreamLabel1); 1494 AddVideoStream(kStreamLabel1);
1497 1495
1498 CreateOfferAsRemoteDescription(); 1496 CreateOfferAsRemoteDescription();
1499 CreatePrAnswerAsLocalDescription(); 1497 CreatePrAnswerAsLocalDescription();
1500 CreateAnswerAsLocalDescription(); 1498 CreateAnswerAsLocalDescription();
1501 1499
1502 WaitAndVerifyOnAddStream(kStreamLabel1); 1500 WaitAndVerifyOnAddStream(kStreamLabel1);
1503 } 1501 }
1504 1502
1505 TEST_F(PeerConnectionInterfaceTest, Renegotiate) { 1503 TEST_F(PeerConnectionInterfaceTest, Renegotiate) {
1506 InitiateCall(); 1504 InitiateCall();
1507 ASSERT_EQ(1u, pc_->remote_streams()->count()); 1505 ASSERT_EQ(1u, pc_->remote_streams()->count());
1508 pc_->RemoveStream(pc_->local_streams()->at(0)); 1506 pc_->RemoveStream(pc_->local_streams()->at(0));
1509 CreateOfferReceiveAnswer(); 1507 CreateOfferReceiveAnswer();
1510 EXPECT_EQ(0u, pc_->remote_streams()->count()); 1508 EXPECT_EQ(0u, pc_->remote_streams()->count());
1511 AddVideoStream(kStreamLabel1); 1509 AddVideoStream(kStreamLabel1);
1512 CreateOfferReceiveAnswer(); 1510 CreateOfferReceiveAnswer();
1513 } 1511 }
1514 1512
1515 // Tests that after negotiating an audio only call, the respondent can perform a 1513 // Tests that after negotiating an audio only call, the respondent can perform a
1516 // renegotiation that removes the audio stream. 1514 // renegotiation that removes the audio stream.
1517 TEST_F(PeerConnectionInterfaceTest, RenegotiateAudioOnly) { 1515 TEST_F(PeerConnectionInterfaceTest, RenegotiateAudioOnly) {
1518 CreatePeerConnectionWithoutDtls(); 1516 CreatePeerConnection();
1519 AddVoiceStream(kStreamLabel1); 1517 AddVoiceStream(kStreamLabel1);
1520 CreateOfferAsRemoteDescription(); 1518 CreateOfferAsRemoteDescription();
1521 CreateAnswerAsLocalDescription(); 1519 CreateAnswerAsLocalDescription();
1522 1520
1523 ASSERT_EQ(1u, pc_->remote_streams()->count()); 1521 ASSERT_EQ(1u, pc_->remote_streams()->count());
1524 pc_->RemoveStream(pc_->local_streams()->at(0)); 1522 pc_->RemoveStream(pc_->local_streams()->at(0));
1525 CreateOfferReceiveAnswer(); 1523 CreateOfferReceiveAnswer();
1526 EXPECT_EQ(0u, pc_->remote_streams()->count()); 1524 EXPECT_EQ(0u, pc_->remote_streams()->count());
1527 } 1525 }
1528 1526
1529 // Test that candidates are generated and that we can parse our own candidates. 1527 // Test that candidates are generated and that we can parse our own candidates.
1530 TEST_F(PeerConnectionInterfaceTest, IceCandidates) { 1528 TEST_F(PeerConnectionInterfaceTest, IceCandidates) {
1531 CreatePeerConnectionWithoutDtls(); 1529 CreatePeerConnection();
1532 1530
1533 EXPECT_FALSE(pc_->AddIceCandidate(observer_.last_candidate_.get())); 1531 EXPECT_FALSE(pc_->AddIceCandidate(observer_.last_candidate_.get()));
1534 // SetRemoteDescription takes ownership of offer. 1532 // SetRemoteDescription takes ownership of offer.
1535 std::unique_ptr<SessionDescriptionInterface> offer; 1533 std::unique_ptr<SessionDescriptionInterface> offer;
1536 AddVideoStream(kStreamLabel1); 1534 AddVideoStream(kStreamLabel1);
1537 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); 1535 EXPECT_TRUE(DoCreateOffer(&offer, nullptr));
1538 EXPECT_TRUE(DoSetRemoteDescription(offer.release())); 1536 EXPECT_TRUE(DoSetRemoteDescription(offer.release()));
1539 1537
1540 // SetLocalDescription takes ownership of answer. 1538 // SetLocalDescription takes ownership of answer.
1541 std::unique_ptr<SessionDescriptionInterface> answer; 1539 std::unique_ptr<SessionDescriptionInterface> answer;
1542 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); 1540 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr));
1543 EXPECT_TRUE(DoSetLocalDescription(answer.release())); 1541 EXPECT_TRUE(DoSetLocalDescription(answer.release()));
1544 1542
1545 EXPECT_TRUE_WAIT(observer_.last_candidate_.get() != NULL, kTimeout); 1543 EXPECT_TRUE_WAIT(observer_.last_candidate_.get() != NULL, kTimeout);
1546 EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout); 1544 EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout);
1547 1545
1548 EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate_.get())); 1546 EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate_.get()));
1549 } 1547 }
1550 1548
1551 // Test that CreateOffer and CreateAnswer will fail if the track labels are 1549 // Test that CreateOffer and CreateAnswer will fail if the track labels are
1552 // not unique. 1550 // not unique.
1553 TEST_F(PeerConnectionInterfaceTest, CreateOfferAnswerWithInvalidStream) { 1551 TEST_F(PeerConnectionInterfaceTest, CreateOfferAnswerWithInvalidStream) {
1554 CreatePeerConnectionWithoutDtls(); 1552 CreatePeerConnection();
1555 // Create a regular offer for the CreateAnswer test later. 1553 // Create a regular offer for the CreateAnswer test later.
1556 std::unique_ptr<SessionDescriptionInterface> offer; 1554 std::unique_ptr<SessionDescriptionInterface> offer;
1557 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); 1555 EXPECT_TRUE(DoCreateOffer(&offer, nullptr));
1558 EXPECT_TRUE(offer); 1556 EXPECT_TRUE(offer);
1559 offer.reset(); 1557 offer.reset();
1560 1558
1561 // Create a local stream with audio&video tracks having same label. 1559 // Create a local stream with audio&video tracks having same label.
1562 AddAudioVideoStream(kStreamLabel1, "track_label", "track_label"); 1560 AddAudioVideoStream(kStreamLabel1, "track_label", "track_label");
1563 1561
1564 // Test CreateOffer 1562 // Test CreateOffer
1565 EXPECT_FALSE(DoCreateOffer(&offer, nullptr)); 1563 EXPECT_FALSE(DoCreateOffer(&offer, nullptr));
1566 1564
1567 // Test CreateAnswer 1565 // Test CreateAnswer
1568 std::unique_ptr<SessionDescriptionInterface> answer; 1566 std::unique_ptr<SessionDescriptionInterface> answer;
1569 EXPECT_FALSE(DoCreateAnswer(&answer, nullptr)); 1567 EXPECT_FALSE(DoCreateAnswer(&answer, nullptr));
1570 } 1568 }
1571 1569
1572 // Test that we will get different SSRCs for each tracks in the offer and answer 1570 // Test that we will get different SSRCs for each tracks in the offer and answer
1573 // we created. 1571 // we created.
1574 TEST_F(PeerConnectionInterfaceTest, SsrcInOfferAnswer) { 1572 TEST_F(PeerConnectionInterfaceTest, SsrcInOfferAnswer) {
1575 CreatePeerConnectionWithoutDtls(); 1573 CreatePeerConnection();
1576 // Create a local stream with audio&video tracks having different labels. 1574 // Create a local stream with audio&video tracks having different labels.
1577 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); 1575 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label");
1578 1576
1579 // Test CreateOffer 1577 // Test CreateOffer
1580 std::unique_ptr<SessionDescriptionInterface> offer; 1578 std::unique_ptr<SessionDescriptionInterface> offer;
1581 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); 1579 ASSERT_TRUE(DoCreateOffer(&offer, nullptr));
1582 int audio_ssrc = 0; 1580 int audio_ssrc = 0;
1583 int video_ssrc = 0; 1581 int video_ssrc = 0;
1584 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(offer->description()), 1582 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(offer->description()),
1585 &audio_ssrc)); 1583 &audio_ssrc));
(...skipping 11 matching lines...) Expand all
1597 &audio_ssrc)); 1595 &audio_ssrc));
1598 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(answer->description()), 1596 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(answer->description()),
1599 &video_ssrc)); 1597 &video_ssrc));
1600 EXPECT_NE(audio_ssrc, video_ssrc); 1598 EXPECT_NE(audio_ssrc, video_ssrc);
1601 } 1599 }
1602 1600
1603 // Test that it's possible to call AddTrack on a MediaStream after adding 1601 // Test that it's possible to call AddTrack on a MediaStream after adding
1604 // the stream to a PeerConnection. 1602 // the stream to a PeerConnection.
1605 // TODO(deadbeef): Remove this test once this behavior is no longer supported. 1603 // TODO(deadbeef): Remove this test once this behavior is no longer supported.
1606 TEST_F(PeerConnectionInterfaceTest, AddTrackAfterAddStream) { 1604 TEST_F(PeerConnectionInterfaceTest, AddTrackAfterAddStream) {
1607 CreatePeerConnectionWithoutDtls(); 1605 CreatePeerConnection();
1608 // Create audio stream and add to PeerConnection. 1606 // Create audio stream and add to PeerConnection.
1609 AddVoiceStream(kStreamLabel1); 1607 AddVoiceStream(kStreamLabel1);
1610 MediaStreamInterface* stream = pc_->local_streams()->at(0); 1608 MediaStreamInterface* stream = pc_->local_streams()->at(0);
1611 1609
1612 // Add video track to the audio-only stream. 1610 // Add video track to the audio-only stream.
1613 rtc::scoped_refptr<VideoTrackInterface> video_track( 1611 rtc::scoped_refptr<VideoTrackInterface> video_track(
1614 pc_factory_->CreateVideoTrack( 1612 pc_factory_->CreateVideoTrack(
1615 "video_label", 1613 "video_label",
1616 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer()))); 1614 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer())));
1617 stream->AddTrack(video_track.get()); 1615 stream->AddTrack(video_track.get());
1618 1616
1619 std::unique_ptr<SessionDescriptionInterface> offer; 1617 std::unique_ptr<SessionDescriptionInterface> offer;
1620 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); 1618 ASSERT_TRUE(DoCreateOffer(&offer, nullptr));
1621 1619
1622 const cricket::MediaContentDescription* video_desc = 1620 const cricket::MediaContentDescription* video_desc =
1623 cricket::GetFirstVideoContentDescription(offer->description()); 1621 cricket::GetFirstVideoContentDescription(offer->description());
1624 EXPECT_TRUE(video_desc != nullptr); 1622 EXPECT_TRUE(video_desc != nullptr);
1625 } 1623 }
1626 1624
1627 // Test that it's possible to call RemoveTrack on a MediaStream after adding 1625 // Test that it's possible to call RemoveTrack on a MediaStream after adding
1628 // the stream to a PeerConnection. 1626 // the stream to a PeerConnection.
1629 // TODO(deadbeef): Remove this test once this behavior is no longer supported. 1627 // TODO(deadbeef): Remove this test once this behavior is no longer supported.
1630 TEST_F(PeerConnectionInterfaceTest, RemoveTrackAfterAddStream) { 1628 TEST_F(PeerConnectionInterfaceTest, RemoveTrackAfterAddStream) {
1631 CreatePeerConnectionWithoutDtls(); 1629 CreatePeerConnection();
1632 // Create audio/video stream and add to PeerConnection. 1630 // Create audio/video stream and add to PeerConnection.
1633 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); 1631 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label");
1634 MediaStreamInterface* stream = pc_->local_streams()->at(0); 1632 MediaStreamInterface* stream = pc_->local_streams()->at(0);
1635 1633
1636 // Remove the video track. 1634 // Remove the video track.
1637 stream->RemoveTrack(stream->GetVideoTracks()[0]); 1635 stream->RemoveTrack(stream->GetVideoTracks()[0]);
1638 1636
1639 std::unique_ptr<SessionDescriptionInterface> offer; 1637 std::unique_ptr<SessionDescriptionInterface> offer;
1640 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); 1638 ASSERT_TRUE(DoCreateOffer(&offer, nullptr));
1641 1639
1642 const cricket::MediaContentDescription* video_desc = 1640 const cricket::MediaContentDescription* video_desc =
1643 cricket::GetFirstVideoContentDescription(offer->description()); 1641 cricket::GetFirstVideoContentDescription(offer->description());
1644 EXPECT_TRUE(video_desc == nullptr); 1642 EXPECT_TRUE(video_desc == nullptr);
1645 } 1643 }
1646 1644
1647 // Test creating a sender with a stream ID, and ensure the ID is populated 1645 // Test creating a sender with a stream ID, and ensure the ID is populated
1648 // in the offer. 1646 // in the offer.
1649 TEST_F(PeerConnectionInterfaceTest, CreateSenderWithStream) { 1647 TEST_F(PeerConnectionInterfaceTest, CreateSenderWithStream) {
1650 CreatePeerConnectionWithoutDtls(); 1648 CreatePeerConnection();
1651 pc_->CreateSender("video", kStreamLabel1); 1649 pc_->CreateSender("video", kStreamLabel1);
1652 1650
1653 std::unique_ptr<SessionDescriptionInterface> offer; 1651 std::unique_ptr<SessionDescriptionInterface> offer;
1654 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); 1652 ASSERT_TRUE(DoCreateOffer(&offer, nullptr));
1655 1653
1656 const cricket::MediaContentDescription* video_desc = 1654 const cricket::MediaContentDescription* video_desc =
1657 cricket::GetFirstVideoContentDescription(offer->description()); 1655 cricket::GetFirstVideoContentDescription(offer->description());
1658 ASSERT_TRUE(video_desc != nullptr); 1656 ASSERT_TRUE(video_desc != nullptr);
1659 ASSERT_EQ(1u, video_desc->streams().size()); 1657 ASSERT_EQ(1u, video_desc->streams().size());
1660 EXPECT_EQ(kStreamLabel1, video_desc->streams()[0].sync_label); 1658 EXPECT_EQ(kStreamLabel1, video_desc->streams()[0].sync_label);
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 cricket::GetFirstDataContent(pc_->local_description()->description()); 2068 cricket::GetFirstDataContent(pc_->local_description()->description());
2071 ASSERT_TRUE(content != NULL); 2069 ASSERT_TRUE(content != NULL);
2072 EXPECT_TRUE(content->rejected); 2070 EXPECT_TRUE(content->rejected);
2073 #endif 2071 #endif
2074 } 2072 }
2075 2073
2076 // Test that we can create an audio only offer and receive an answer with a 2074 // Test that we can create an audio only offer and receive an answer with a
2077 // limited set of audio codecs and receive an updated offer with more audio 2075 // limited set of audio codecs and receive an updated offer with more audio
2078 // codecs, where the added codecs are not supported. 2076 // codecs, where the added codecs are not supported.
2079 TEST_F(PeerConnectionInterfaceTest, ReceiveUpdatedAudioOfferWithBadCodecs) { 2077 TEST_F(PeerConnectionInterfaceTest, ReceiveUpdatedAudioOfferWithBadCodecs) {
2080 CreatePeerConnectionWithoutDtls(); 2078 CreatePeerConnection();
2081 AddVoiceStream("audio_label"); 2079 AddVoiceStream("audio_label");
2082 CreateOfferAsLocalDescription(); 2080 CreateOfferAsLocalDescription();
2083 2081
2084 SessionDescriptionInterface* answer = 2082 SessionDescriptionInterface* answer =
2085 webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer, 2083 webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer,
2086 webrtc::kAudioSdp, nullptr); 2084 webrtc::kAudioSdp, nullptr);
2087 EXPECT_TRUE(DoSetSessionDescription(answer, false)); 2085 EXPECT_TRUE(DoSetSessionDescription(answer, false));
2088 2086
2089 SessionDescriptionInterface* updated_offer = 2087 SessionDescriptionInterface* updated_offer =
2090 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, 2088 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 } 2176 }
2179 2177
2180 TEST_F(PeerConnectionInterfaceTest, SetConfigurationChangesCandidateFilter) { 2178 TEST_F(PeerConnectionInterfaceTest, SetConfigurationChangesCandidateFilter) {
2181 CreatePeerConnection(); 2179 CreatePeerConnection();
2182 PeerConnectionInterface::RTCConfiguration config; 2180 PeerConnectionInterface::RTCConfiguration config;
2183 config.type = PeerConnectionInterface::kRelay; 2181 config.type = PeerConnectionInterface::kRelay;
2184 EXPECT_TRUE(pc_->SetConfiguration(config)); 2182 EXPECT_TRUE(pc_->SetConfiguration(config));
2185 EXPECT_EQ(cricket::CF_RELAY, port_allocator_->candidate_filter()); 2183 EXPECT_EQ(cricket::CF_RELAY, port_allocator_->candidate_filter());
2186 } 2184 }
2187 2185
2188 TEST_F(PeerConnectionInterfaceTest, SetConfigurationChangesPruneTurnPortsFlag) {
2189 PeerConnectionInterface::RTCConfiguration config;
2190 config.prune_turn_ports = false;
2191 CreatePeerConnection(config, nullptr);
2192 EXPECT_FALSE(port_allocator_->prune_turn_ports());
2193
2194 config.prune_turn_ports = true;
2195 EXPECT_TRUE(pc_->SetConfiguration(config));
2196 EXPECT_TRUE(port_allocator_->prune_turn_ports());
2197 }
2198
2199 // Test that when SetConfiguration changes both the pool size and other 2186 // Test that when SetConfiguration changes both the pool size and other
2200 // attributes, the pooled session is created with the updated attributes. 2187 // attributes, the pooled session is created with the updated attributes.
2201 TEST_F(PeerConnectionInterfaceTest, 2188 TEST_F(PeerConnectionInterfaceTest,
2202 SetConfigurationCreatesPooledSessionCorrectly) { 2189 SetConfigurationCreatesPooledSessionCorrectly) {
2203 CreatePeerConnection(); 2190 CreatePeerConnection();
2204 PeerConnectionInterface::RTCConfiguration config; 2191 PeerConnectionInterface::RTCConfiguration config;
2205 config.ice_candidate_pool_size = 1; 2192 config.ice_candidate_pool_size = 1;
2206 PeerConnectionInterface::IceServer server; 2193 PeerConnectionInterface::IceServer server;
2207 server.uri = kStunAddressOnly; 2194 server.uri = kStunAddressOnly;
2208 config.servers.push_back(server); 2195 config.servers.push_back(server);
2209 config.type = PeerConnectionInterface::kRelay; 2196 config.type = PeerConnectionInterface::kRelay;
2210 EXPECT_TRUE(pc_->SetConfiguration(config)); 2197 EXPECT_TRUE(pc_->SetConfiguration(config));
2211 2198
2212 const cricket::FakePortAllocatorSession* session = 2199 const cricket::FakePortAllocatorSession* session =
2213 static_cast<const cricket::FakePortAllocatorSession*>( 2200 static_cast<const cricket::FakePortAllocatorSession*>(
2214 port_allocator_->GetPooledSession()); 2201 port_allocator_->GetPooledSession());
2215 ASSERT_NE(nullptr, session); 2202 ASSERT_NE(nullptr, session);
2216 EXPECT_EQ(1UL, session->stun_servers().size()); 2203 EXPECT_EQ(1UL, session->stun_servers().size());
2217 } 2204 }
2218 2205
2219 // Test that after SetLocalDescription, changing the pool size is not allowed, 2206 // Test that after SetLocalDescription, changing the pool size is not allowed.
2220 // and an invalid modification error is returned.
2221 TEST_F(PeerConnectionInterfaceTest, 2207 TEST_F(PeerConnectionInterfaceTest,
2222 CantChangePoolSizeAfterSetLocalDescription) { 2208 CantChangePoolSizeAfterSetLocalDescription) {
2223 CreatePeerConnection(); 2209 CreatePeerConnection();
2224 // Start by setting a size of 1. 2210 // Start by setting a size of 1.
2225 PeerConnectionInterface::RTCConfiguration config; 2211 PeerConnectionInterface::RTCConfiguration config;
2226 config.ice_candidate_pool_size = 1; 2212 config.ice_candidate_pool_size = 1;
2227 EXPECT_TRUE(pc_->SetConfiguration(config)); 2213 EXPECT_TRUE(pc_->SetConfiguration(config));
2228 2214
2229 // Set remote offer; can still change pool size at this point. 2215 // Set remote offer; can still change pool size at this point.
2230 CreateOfferAsRemoteDescription(); 2216 CreateOfferAsRemoteDescription();
2231 config.ice_candidate_pool_size = 2; 2217 config.ice_candidate_pool_size = 2;
2232 EXPECT_TRUE(pc_->SetConfiguration(config)); 2218 EXPECT_TRUE(pc_->SetConfiguration(config));
2233 2219
2234 // Set local answer; now it's too late. 2220 // Set local answer; now it's too late.
2235 CreateAnswerAsLocalDescription(); 2221 CreateAnswerAsLocalDescription();
2236 config.ice_candidate_pool_size = 3; 2222 config.ice_candidate_pool_size = 3;
2237 RTCError error; 2223 EXPECT_FALSE(pc_->SetConfiguration(config));
2238 EXPECT_FALSE(pc_->SetConfiguration(config, &error));
2239 EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, error.type());
2240 }
2241
2242 // Test that SetConfiguration returns an invalid modification error if
2243 // modifying a field in the configuration that isn't allowed to be modified.
2244 TEST_F(PeerConnectionInterfaceTest,
2245 SetConfigurationReturnsInvalidModificationError) {
2246 PeerConnectionInterface::RTCConfiguration config;
2247 config.bundle_policy = PeerConnectionInterface::kBundlePolicyBalanced;
2248 config.rtcp_mux_policy = PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
2249 config.continual_gathering_policy = PeerConnectionInterface::GATHER_ONCE;
2250 CreatePeerConnection(config, nullptr);
2251
2252 PeerConnectionInterface::RTCConfiguration modified_config = config;
2253 modified_config.bundle_policy =
2254 PeerConnectionInterface::kBundlePolicyMaxBundle;
2255 RTCError error;
2256 EXPECT_FALSE(pc_->SetConfiguration(modified_config, &error));
2257 EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, error.type());
2258
2259 modified_config = config;
2260 modified_config.rtcp_mux_policy =
2261 PeerConnectionInterface::kRtcpMuxPolicyRequire;
2262 error.set_type(RTCErrorType::NONE);
2263 EXPECT_FALSE(pc_->SetConfiguration(modified_config, &error));
2264 EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, error.type());
2265
2266 modified_config = config;
2267 modified_config.continual_gathering_policy =
2268 PeerConnectionInterface::GATHER_CONTINUALLY;
2269 error.set_type(RTCErrorType::NONE);
2270 EXPECT_FALSE(pc_->SetConfiguration(modified_config, &error));
2271 EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, error.type());
2272 }
2273
2274 // Test that SetConfiguration returns a range error if the candidate pool size
2275 // is negative or larger than allowed by the spec.
2276 TEST_F(PeerConnectionInterfaceTest,
2277 SetConfigurationReturnsRangeErrorForBadCandidatePoolSize) {
2278 PeerConnectionInterface::RTCConfiguration config;
2279 CreatePeerConnection(config, nullptr);
2280
2281 config.ice_candidate_pool_size = -1;
2282 RTCError error;
2283 EXPECT_FALSE(pc_->SetConfiguration(config, &error));
2284 EXPECT_EQ(RTCErrorType::INVALID_RANGE, error.type());
2285
2286 config.ice_candidate_pool_size = INT_MAX;
2287 error.set_type(RTCErrorType::NONE);
2288 EXPECT_FALSE(pc_->SetConfiguration(config, &error));
2289 EXPECT_EQ(RTCErrorType::INVALID_RANGE, error.type());
2290 }
2291
2292 // Test that SetConfiguration returns a syntax error if parsing an ICE server
2293 // URL failed.
2294 TEST_F(PeerConnectionInterfaceTest,
2295 SetConfigurationReturnsSyntaxErrorFromBadIceUrls) {
2296 PeerConnectionInterface::RTCConfiguration config;
2297 CreatePeerConnection(config, nullptr);
2298
2299 PeerConnectionInterface::IceServer bad_server;
2300 bad_server.uri = "stunn:www.example.com";
2301 config.servers.push_back(bad_server);
2302 RTCError error;
2303 EXPECT_FALSE(pc_->SetConfiguration(config, &error));
2304 EXPECT_EQ(RTCErrorType::SYNTAX_ERROR, error.type());
2305 }
2306
2307 // Test that SetConfiguration returns an invalid parameter error if a TURN
2308 // IceServer is missing a username or password.
2309 TEST_F(PeerConnectionInterfaceTest,
2310 SetConfigurationReturnsInvalidParameterIfCredentialsMissing) {
2311 PeerConnectionInterface::RTCConfiguration config;
2312 CreatePeerConnection(config, nullptr);
2313
2314 PeerConnectionInterface::IceServer bad_server;
2315 bad_server.uri = "turn:www.example.com";
2316 // Missing password.
2317 bad_server.username = "foo";
2318 config.servers.push_back(bad_server);
2319 RTCError error;
2320 EXPECT_FALSE(pc_->SetConfiguration(config, &error));
2321 EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, error.type());
2322 } 2224 }
2323 2225
2324 // Test that PeerConnection::Close changes the states to closed and all remote 2226 // Test that PeerConnection::Close changes the states to closed and all remote
2325 // tracks change state to ended. 2227 // tracks change state to ended.
2326 TEST_F(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) { 2228 TEST_F(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) {
2327 // Initialize a PeerConnection and negotiate local and remote session 2229 // Initialize a PeerConnection and negotiate local and remote session
2328 // description. 2230 // description.
2329 InitiateCall(); 2231 InitiateCall();
2330 ASSERT_EQ(1u, pc_->local_streams()->count()); 2232 ASSERT_EQ(1u, pc_->local_streams()->count());
2331 ASSERT_EQ(1u, pc_->remote_streams()->count()); 2233 ASSERT_EQ(1u, pc_->remote_streams()->count());
(...skipping 14 matching lines...) Expand all
2346 // Track state may be updated asynchronously. 2248 // Track state may be updated asynchronously.
2347 EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded, 2249 EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded,
2348 remote_stream->GetAudioTracks()[0]->state(), kTimeout); 2250 remote_stream->GetAudioTracks()[0]->state(), kTimeout);
2349 EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded, 2251 EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded,
2350 remote_stream->GetVideoTracks()[0]->state(), kTimeout); 2252 remote_stream->GetVideoTracks()[0]->state(), kTimeout);
2351 } 2253 }
2352 2254
2353 // Test that PeerConnection methods fails gracefully after 2255 // Test that PeerConnection methods fails gracefully after
2354 // PeerConnection::Close has been called. 2256 // PeerConnection::Close has been called.
2355 TEST_F(PeerConnectionInterfaceTest, CloseAndTestMethods) { 2257 TEST_F(PeerConnectionInterfaceTest, CloseAndTestMethods) {
2356 CreatePeerConnectionWithoutDtls(); 2258 CreatePeerConnection();
2357 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); 2259 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label");
2358 CreateOfferAsRemoteDescription(); 2260 CreateOfferAsRemoteDescription();
2359 CreateAnswerAsLocalDescription(); 2261 CreateAnswerAsLocalDescription();
2360 2262
2361 ASSERT_EQ(1u, pc_->local_streams()->count()); 2263 ASSERT_EQ(1u, pc_->local_streams()->count());
2362 rtc::scoped_refptr<MediaStreamInterface> local_stream = 2264 rtc::scoped_refptr<MediaStreamInterface> local_stream =
2363 pc_->local_streams()->at(0); 2265 pc_->local_streams()->at(0);
2364 2266
2365 pc_->Close(); 2267 pc_->Close();
2366 2268
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
3248 answer_c.SetMandatoryReceiveAudio(false); 3150 answer_c.SetMandatoryReceiveAudio(false);
3249 answer_c.SetMandatoryReceiveVideo(false); 3151 answer_c.SetMandatoryReceiveVideo(false);
3250 3152
3251 cricket::MediaSessionOptions updated_answer_options; 3153 cricket::MediaSessionOptions updated_answer_options;
3252 EXPECT_TRUE( 3154 EXPECT_TRUE(
3253 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); 3155 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options));
3254 EXPECT_TRUE(updated_answer_options.has_audio()); 3156 EXPECT_TRUE(updated_answer_options.has_audio());
3255 EXPECT_TRUE(updated_answer_options.has_video()); 3157 EXPECT_TRUE(updated_answer_options.has_video());
3256 } 3158 }
3257 3159
3258 TEST(RTCErrorTypeTest, OstreamOperator) { 3160 TEST(RtcErrorTest, OstreamOperator) {
3259 std::ostringstream oss; 3161 std::ostringstream oss;
3260 oss << webrtc::RTCErrorType::NONE << ' ' 3162 oss << webrtc::RtcError::NONE << ' '
3261 << webrtc::RTCErrorType::INVALID_PARAMETER << ' ' 3163 << webrtc::RtcError::INVALID_PARAMETER << ' '
3262 << webrtc::RTCErrorType::INTERNAL_ERROR; 3164 << webrtc::RtcError::INTERNAL_ERROR;
3263 EXPECT_EQ("NONE INVALID_PARAMETER INTERNAL_ERROR", oss.str()); 3165 EXPECT_EQ("NONE INVALID_PARAMETER INTERNAL_ERROR", oss.str());
3264 } 3166 }
3265
3266 // Tests a few random fields being different.
3267 TEST(RTCConfigurationTest, ComparisonOperators) {
3268 PeerConnectionInterface::RTCConfiguration a;
3269 PeerConnectionInterface::RTCConfiguration b;
3270 EXPECT_EQ(a, b);
3271
3272 PeerConnectionInterface::RTCConfiguration c;
3273 c.servers.push_back(PeerConnectionInterface::IceServer());
3274 EXPECT_NE(a, c);
3275
3276 PeerConnectionInterface::RTCConfiguration d;
3277 d.type = PeerConnectionInterface::kRelay;
3278 EXPECT_NE(a, d);
3279
3280 PeerConnectionInterface::RTCConfiguration e;
3281 e.audio_jitter_buffer_max_packets = 5;
3282 EXPECT_NE(a, e);
3283
3284 PeerConnectionInterface::RTCConfiguration f;
3285 f.ice_connection_receiving_timeout = 1337;
3286 EXPECT_NE(a, f);
3287
3288 PeerConnectionInterface::RTCConfiguration g;
3289 g.disable_ipv6 = true;
3290 EXPECT_NE(a, g);
3291
3292 PeerConnectionInterface::RTCConfiguration h(
3293 PeerConnectionInterface::RTCConfigurationType::kAggressive);
3294 EXPECT_NE(a, h);
3295 }
OLDNEW
« no previous file with comments | « webrtc/api/peerconnectioninterface.h ('k') | webrtc/api/peerconnectionproxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698