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

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

Issue 1972043004: Revert of Implement RTCConfiguration.iceCandidatePoolSize. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebasing Created 4 years, 7 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/test/peerconnectiontestwrapper.cc » ('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 21 matching lines...) Expand all
32 #include "webrtc/api/test/testsdpstrings.h" 32 #include "webrtc/api/test/testsdpstrings.h"
33 #include "webrtc/api/videocapturertracksource.h" 33 #include "webrtc/api/videocapturertracksource.h"
34 #include "webrtc/api/videotrack.h" 34 #include "webrtc/api/videotrack.h"
35 #include "webrtc/base/gunit.h" 35 #include "webrtc/base/gunit.h"
36 #include "webrtc/base/ssladapter.h" 36 #include "webrtc/base/ssladapter.h"
37 #include "webrtc/base/sslstreamadapter.h" 37 #include "webrtc/base/sslstreamadapter.h"
38 #include "webrtc/base/stringutils.h" 38 #include "webrtc/base/stringutils.h"
39 #include "webrtc/base/thread.h" 39 #include "webrtc/base/thread.h"
40 #include "webrtc/media/base/fakevideocapturer.h" 40 #include "webrtc/media/base/fakevideocapturer.h"
41 #include "webrtc/media/sctp/sctpdataengine.h" 41 #include "webrtc/media/sctp/sctpdataengine.h"
42 #include "webrtc/p2p/base/fakeportallocator.h" 42 #include "webrtc/p2p/client/fakeportallocator.h"
43 #include "webrtc/pc/mediasession.h" 43 #include "webrtc/pc/mediasession.h"
44 44
45 static const char kStreamLabel1[] = "local_stream_1"; 45 static const char kStreamLabel1[] = "local_stream_1";
46 static const char kStreamLabel2[] = "local_stream_2"; 46 static const char kStreamLabel2[] = "local_stream_2";
47 static const char kStreamLabel3[] = "local_stream_3"; 47 static const char kStreamLabel3[] = "local_stream_3";
48 static const int kDefaultStunPort = 3478; 48 static const int kDefaultStunPort = 3478;
49 static const char kStunAddressOnly[] = "stun:address"; 49 static const char kStunAddressOnly[] = "stun:address";
50 static const char kStunInvalidPort[] = "stun:address:-1"; 50 static const char kStunInvalidPort[] = "stun:address:-1";
51 static const char kStunAddressPortAndMore1[] = "stun:address:port:more"; 51 static const char kStunAddressPortAndMore1[] = "stun:address:port:more";
52 static const char kStunAddressPortAndMore2[] = "stun:address:port more"; 52 static const char kStunAddressPortAndMore2[] = "stun:address:port more";
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 } 544 }
545 545
546 virtual void SetUp() { 546 virtual void SetUp() {
547 pc_factory_ = webrtc::CreatePeerConnectionFactory( 547 pc_factory_ = webrtc::CreatePeerConnectionFactory(
548 rtc::Thread::Current(), rtc::Thread::Current(), NULL, NULL, 548 rtc::Thread::Current(), rtc::Thread::Current(), NULL, NULL,
549 NULL); 549 NULL);
550 ASSERT_TRUE(pc_factory_.get() != NULL); 550 ASSERT_TRUE(pc_factory_.get() != NULL);
551 } 551 }
552 552
553 void CreatePeerConnection() { 553 void CreatePeerConnection() {
554 CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(), nullptr); 554 CreatePeerConnection("", "", NULL);
555 } 555 }
556 556
557 void CreatePeerConnection(webrtc::MediaConstraintsInterface* constraints) { 557 void CreatePeerConnection(webrtc::MediaConstraintsInterface* constraints) {
558 CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(), 558 CreatePeerConnection("", "", constraints);
559 constraints);
560 } 559 }
561 560
562 void CreatePeerConnectionWithIceTransportsType( 561 void CreatePeerConnection(const std::string& uri,
563 PeerConnectionInterface::IceTransportsType type) { 562 const std::string& password,
564 PeerConnectionInterface::RTCConfiguration config; 563 webrtc::MediaConstraintsInterface* constraints) {
565 config.type = type;
566 return CreatePeerConnection(config, nullptr);
567 }
568
569 void CreatePeerConnectionWithIceServer(const std::string& uri,
570 const std::string& password) {
571 PeerConnectionInterface::RTCConfiguration config; 564 PeerConnectionInterface::RTCConfiguration config;
572 PeerConnectionInterface::IceServer server; 565 PeerConnectionInterface::IceServer server;
573 server.uri = uri; 566 if (!uri.empty()) {
574 server.password = password; 567 server.uri = uri;
575 config.servers.push_back(server); 568 server.password = password;
576 CreatePeerConnection(config, nullptr); 569 config.servers.push_back(server);
577 } 570 }
578 571
579 void CreatePeerConnection(PeerConnectionInterface::RTCConfiguration config,
580 webrtc::MediaConstraintsInterface* constraints) {
581 std::unique_ptr<cricket::FakePortAllocator> port_allocator( 572 std::unique_ptr<cricket::FakePortAllocator> port_allocator(
582 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr)); 573 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr));
583 port_allocator_ = port_allocator.get(); 574 port_allocator_ = port_allocator.get();
584 575
585 // DTLS does not work in a loopback call, so is disabled for most of the 576 // DTLS does not work in a loopback call, so is disabled for most of the
586 // tests in this file. We only create a FakeIdentityService if the test 577 // tests in this file. We only create a FakeIdentityService if the test
587 // explicitly sets the constraint. 578 // explicitly sets the constraint.
588 FakeConstraints default_constraints; 579 FakeConstraints default_constraints;
589 if (!constraints) { 580 if (!constraints) {
590 constraints = &default_constraints; 581 constraints = &default_constraints;
(...skipping 24 matching lines...) Expand all
615 server.uri = uri; 606 server.uri = uri;
616 config.servers.push_back(server); 607 config.servers.push_back(server);
617 608
618 scoped_refptr<PeerConnectionInterface> pc; 609 scoped_refptr<PeerConnectionInterface> pc;
619 pc = pc_factory_->CreatePeerConnection(config, nullptr, nullptr, nullptr, 610 pc = pc_factory_->CreatePeerConnection(config, nullptr, nullptr, nullptr,
620 &observer_); 611 &observer_);
621 EXPECT_EQ(nullptr, pc); 612 EXPECT_EQ(nullptr, pc);
622 } 613 }
623 614
624 void CreatePeerConnectionWithDifferentConfigurations() { 615 void CreatePeerConnectionWithDifferentConfigurations() {
625 CreatePeerConnectionWithIceServer(kStunAddressOnly, ""); 616 CreatePeerConnection(kStunAddressOnly, "", NULL);
626 EXPECT_EQ(1u, port_allocator_->stun_servers().size()); 617 EXPECT_EQ(1u, port_allocator_->stun_servers().size());
627 EXPECT_EQ(0u, port_allocator_->turn_servers().size()); 618 EXPECT_EQ(0u, port_allocator_->turn_servers().size());
628 EXPECT_EQ("address", port_allocator_->stun_servers().begin()->hostname()); 619 EXPECT_EQ("address", port_allocator_->stun_servers().begin()->hostname());
629 EXPECT_EQ(kDefaultStunPort, 620 EXPECT_EQ(kDefaultStunPort,
630 port_allocator_->stun_servers().begin()->port()); 621 port_allocator_->stun_servers().begin()->port());
631 622
632 CreatePeerConnectionExpectFail(kStunInvalidPort); 623 CreatePeerConnectionExpectFail(kStunInvalidPort);
633 CreatePeerConnectionExpectFail(kStunAddressPortAndMore1); 624 CreatePeerConnectionExpectFail(kStunAddressPortAndMore1);
634 CreatePeerConnectionExpectFail(kStunAddressPortAndMore2); 625 CreatePeerConnectionExpectFail(kStunAddressPortAndMore2);
635 626
636 CreatePeerConnectionWithIceServer(kTurnIceServerUri, kTurnPassword); 627 CreatePeerConnection(kTurnIceServerUri, kTurnPassword, NULL);
637 EXPECT_EQ(0u, port_allocator_->stun_servers().size()); 628 EXPECT_EQ(0u, port_allocator_->stun_servers().size());
638 EXPECT_EQ(1u, port_allocator_->turn_servers().size()); 629 EXPECT_EQ(1u, port_allocator_->turn_servers().size());
639 EXPECT_EQ(kTurnUsername, 630 EXPECT_EQ(kTurnUsername,
640 port_allocator_->turn_servers()[0].credentials.username); 631 port_allocator_->turn_servers()[0].credentials.username);
641 EXPECT_EQ(kTurnPassword, 632 EXPECT_EQ(kTurnPassword,
642 port_allocator_->turn_servers()[0].credentials.password); 633 port_allocator_->turn_servers()[0].credentials.password);
643 EXPECT_EQ(kTurnHostname, 634 EXPECT_EQ(kTurnHostname,
644 port_allocator_->turn_servers()[0].ports[0].address.hostname()); 635 port_allocator_->turn_servers()[0].ports[0].address.hostname());
645 } 636 }
646 637
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 CreateAnswerWithOneAudioStream(); 1007 CreateAnswerWithOneAudioStream();
1017 EXPECT_NE(GetFirstAudioStreamCname(answer1.get()), 1008 EXPECT_NE(GetFirstAudioStreamCname(answer1.get()),
1018 GetFirstAudioStreamCname(answer2.get())); 1009 GetFirstAudioStreamCname(answer2.get()));
1019 } 1010 }
1020 1011
1021 TEST_F(PeerConnectionInterfaceTest, 1012 TEST_F(PeerConnectionInterfaceTest,
1022 CreatePeerConnectionWithDifferentConfigurations) { 1013 CreatePeerConnectionWithDifferentConfigurations) {
1023 CreatePeerConnectionWithDifferentConfigurations(); 1014 CreatePeerConnectionWithDifferentConfigurations();
1024 } 1015 }
1025 1016
1026 TEST_F(PeerConnectionInterfaceTest,
1027 CreatePeerConnectionWithDifferentIceTransportsTypes) {
1028 CreatePeerConnectionWithIceTransportsType(PeerConnectionInterface::kNone);
1029 EXPECT_EQ(cricket::CF_NONE, port_allocator_->candidate_filter());
1030 CreatePeerConnectionWithIceTransportsType(PeerConnectionInterface::kRelay);
1031 EXPECT_EQ(cricket::CF_RELAY, port_allocator_->candidate_filter());
1032 CreatePeerConnectionWithIceTransportsType(PeerConnectionInterface::kNoHost);
1033 EXPECT_EQ(cricket::CF_ALL & ~cricket::CF_HOST,
1034 port_allocator_->candidate_filter());
1035 CreatePeerConnectionWithIceTransportsType(PeerConnectionInterface::kAll);
1036 EXPECT_EQ(cricket::CF_ALL, port_allocator_->candidate_filter());
1037 }
1038
1039 // Test that when a PeerConnection is created with a nonzero candidate pool
1040 // size, the pooled PortAllocatorSession is created with all the attributes
1041 // in the RTCConfiguration.
1042 TEST_F(PeerConnectionInterfaceTest, CreatePeerConnectionWithPooledCandidates) {
1043 PeerConnectionInterface::RTCConfiguration config;
1044 PeerConnectionInterface::IceServer server;
1045 server.uri = kStunAddressOnly;
1046 config.servers.push_back(server);
1047 config.type = PeerConnectionInterface::kRelay;
1048 config.disable_ipv6 = true;
1049 config.tcp_candidate_policy =
1050 PeerConnectionInterface::kTcpCandidatePolicyDisabled;
1051 config.ice_candidate_pool_size = 1;
1052 CreatePeerConnection(config, nullptr);
1053
1054 const cricket::FakePortAllocatorSession* session =
1055 static_cast<const cricket::FakePortAllocatorSession*>(
1056 port_allocator_->GetPooledSession());
1057 ASSERT_NE(nullptr, session);
1058 EXPECT_EQ(1UL, session->stun_servers().size());
1059 EXPECT_EQ(0U, session->flags() & cricket::PORTALLOCATOR_ENABLE_IPV6);
1060 EXPECT_LT(0U, session->flags() & cricket::PORTALLOCATOR_DISABLE_TCP);
1061 EXPECT_EQ(cricket::CF_RELAY, session->candidate_filter());
1062 }
1063
1064 TEST_F(PeerConnectionInterfaceTest, AddStreams) { 1017 TEST_F(PeerConnectionInterfaceTest, AddStreams) {
1065 CreatePeerConnection(); 1018 CreatePeerConnection();
1066 AddVideoStream(kStreamLabel1); 1019 AddVideoStream(kStreamLabel1);
1067 AddVoiceStream(kStreamLabel2); 1020 AddVoiceStream(kStreamLabel2);
1068 ASSERT_EQ(2u, pc_->local_streams()->count()); 1021 ASSERT_EQ(2u, pc_->local_streams()->count());
1069 1022
1070 // Test we can add multiple local streams to one peerconnection. 1023 // Test we can add multiple local streams to one peerconnection.
1071 scoped_refptr<MediaStreamInterface> stream( 1024 scoped_refptr<MediaStreamInterface> stream(
1072 pc_factory_->CreateLocalMediaStream(kStreamLabel3)); 1025 pc_factory_->CreateLocalMediaStream(kStreamLabel3));
1073 scoped_refptr<AudioTrackInterface> audio_track( 1026 scoped_refptr<AudioTrackInterface> audio_track(
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 PeerConnectionInterface::IceServer server; 1900 PeerConnectionInterface::IceServer server;
1948 server.uri = "stun:test_hostname"; 1901 server.uri = "stun:test_hostname";
1949 config.servers.push_back(server); 1902 config.servers.push_back(server);
1950 EXPECT_TRUE(pc_->SetConfiguration(config)); 1903 EXPECT_TRUE(pc_->SetConfiguration(config));
1951 1904
1952 EXPECT_EQ(1u, port_allocator_->stun_servers().size()); 1905 EXPECT_EQ(1u, port_allocator_->stun_servers().size());
1953 EXPECT_EQ("test_hostname", 1906 EXPECT_EQ("test_hostname",
1954 port_allocator_->stun_servers().begin()->hostname()); 1907 port_allocator_->stun_servers().begin()->hostname());
1955 } 1908 }
1956 1909
1957 TEST_F(PeerConnectionInterfaceTest, SetConfigurationChangesCandidateFilter) {
1958 CreatePeerConnection();
1959 PeerConnectionInterface::RTCConfiguration config;
1960 config.type = PeerConnectionInterface::kRelay;
1961 EXPECT_TRUE(pc_->SetConfiguration(config));
1962 EXPECT_EQ(cricket::CF_RELAY, port_allocator_->candidate_filter());
1963 }
1964
1965 // Test that when SetConfiguration changes both the pool size and other
1966 // attributes, the pooled session is created with the updated attributes.
1967 TEST_F(PeerConnectionInterfaceTest,
1968 SetConfigurationCreatesPooledSessionCorrectly) {
1969 CreatePeerConnection();
1970 PeerConnectionInterface::RTCConfiguration config;
1971 config.ice_candidate_pool_size = 1;
1972 PeerConnectionInterface::IceServer server;
1973 server.uri = kStunAddressOnly;
1974 config.servers.push_back(server);
1975 config.type = PeerConnectionInterface::kRelay;
1976 CreatePeerConnection(config, nullptr);
1977
1978 const cricket::FakePortAllocatorSession* session =
1979 static_cast<const cricket::FakePortAllocatorSession*>(
1980 port_allocator_->GetPooledSession());
1981 ASSERT_NE(nullptr, session);
1982 EXPECT_EQ(1UL, session->stun_servers().size());
1983 EXPECT_EQ(cricket::CF_RELAY, session->candidate_filter());
1984 }
1985
1986 // Test that PeerConnection::Close changes the states to closed and all remote 1910 // Test that PeerConnection::Close changes the states to closed and all remote
1987 // tracks change state to ended. 1911 // tracks change state to ended.
1988 TEST_F(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) { 1912 TEST_F(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) {
1989 // Initialize a PeerConnection and negotiate local and remote session 1913 // Initialize a PeerConnection and negotiate local and remote session
1990 // description. 1914 // description.
1991 InitiateCall(); 1915 InitiateCall();
1992 ASSERT_EQ(1u, pc_->local_streams()->count()); 1916 ASSERT_EQ(1u, pc_->local_streams()->count());
1993 ASSERT_EQ(1u, pc_->remote_streams()->count()); 1917 ASSERT_EQ(1u, pc_->remote_streams()->count());
1994 1918
1995 pc_->Close(); 1919 pc_->Close();
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
2806 FakeConstraints updated_answer_c; 2730 FakeConstraints updated_answer_c;
2807 answer_c.SetMandatoryReceiveAudio(false); 2731 answer_c.SetMandatoryReceiveAudio(false);
2808 answer_c.SetMandatoryReceiveVideo(false); 2732 answer_c.SetMandatoryReceiveVideo(false);
2809 2733
2810 cricket::MediaSessionOptions updated_answer_options; 2734 cricket::MediaSessionOptions updated_answer_options;
2811 EXPECT_TRUE( 2735 EXPECT_TRUE(
2812 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); 2736 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options));
2813 EXPECT_TRUE(updated_answer_options.has_audio()); 2737 EXPECT_TRUE(updated_answer_options.has_audio());
2814 EXPECT_TRUE(updated_answer_options.has_video()); 2738 EXPECT_TRUE(updated_answer_options.has_video());
2815 } 2739 }
OLDNEW
« no previous file with comments | « webrtc/api/peerconnectioninterface.h ('k') | webrtc/api/test/peerconnectiontestwrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698