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

Unified Diff: webrtc/api/peerconnectioninterface_unittest.cc

Issue 1956453003: Relanding: Implement RTCConfiguration.iceCandidatePoolSize. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing uninitialized variable (noticed by msan) 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/api/peerconnectioninterface.h ('k') | webrtc/api/test/peerconnectiontestwrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/peerconnectioninterface_unittest.cc
diff --git a/webrtc/api/peerconnectioninterface_unittest.cc b/webrtc/api/peerconnectioninterface_unittest.cc
index 2594b6c10637996c3a554757a188da633d5b12cb..ac017a02c57720f7663ec432aa61e9a09bccf117 100644
--- a/webrtc/api/peerconnectioninterface_unittest.cc
+++ b/webrtc/api/peerconnectioninterface_unittest.cc
@@ -39,7 +39,7 @@
#include "webrtc/base/thread.h"
#include "webrtc/media/base/fakevideocapturer.h"
#include "webrtc/media/sctp/sctpdataengine.h"
-#include "webrtc/p2p/client/fakeportallocator.h"
+#include "webrtc/p2p/base/fakeportallocator.h"
#include "webrtc/pc/mediasession.h"
static const char kStreamLabel1[] = "local_stream_1";
@@ -532,24 +532,33 @@ class PeerConnectionInterfaceTest : public testing::Test {
}
void CreatePeerConnection() {
- CreatePeerConnection("", "", NULL);
+ CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(), nullptr);
}
void CreatePeerConnection(webrtc::MediaConstraintsInterface* constraints) {
- CreatePeerConnection("", "", constraints);
+ CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(),
+ constraints);
}
- void CreatePeerConnection(const std::string& uri,
- const std::string& password,
- webrtc::MediaConstraintsInterface* constraints) {
+ void CreatePeerConnectionWithIceTransportsType(
+ PeerConnectionInterface::IceTransportsType type) {
+ PeerConnectionInterface::RTCConfiguration config;
+ config.type = type;
+ return CreatePeerConnection(config, nullptr);
+ }
+
+ void CreatePeerConnectionWithIceServer(const std::string& uri,
+ const std::string& password) {
PeerConnectionInterface::RTCConfiguration config;
PeerConnectionInterface::IceServer server;
- if (!uri.empty()) {
- server.uri = uri;
- server.password = password;
- config.servers.push_back(server);
- }
+ server.uri = uri;
+ server.password = password;
+ config.servers.push_back(server);
+ CreatePeerConnection(config, nullptr);
+ }
+ void CreatePeerConnection(PeerConnectionInterface::RTCConfiguration config,
+ webrtc::MediaConstraintsInterface* constraints) {
std::unique_ptr<cricket::FakePortAllocator> port_allocator(
new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr));
port_allocator_ = port_allocator.get();
@@ -594,7 +603,7 @@ class PeerConnectionInterfaceTest : public testing::Test {
}
void CreatePeerConnectionWithDifferentConfigurations() {
- CreatePeerConnection(kStunAddressOnly, "", NULL);
+ CreatePeerConnectionWithIceServer(kStunAddressOnly, "");
EXPECT_EQ(1u, port_allocator_->stun_servers().size());
EXPECT_EQ(0u, port_allocator_->turn_servers().size());
EXPECT_EQ("address", port_allocator_->stun_servers().begin()->hostname());
@@ -605,7 +614,7 @@ class PeerConnectionInterfaceTest : public testing::Test {
CreatePeerConnectionExpectFail(kStunAddressPortAndMore1);
CreatePeerConnectionExpectFail(kStunAddressPortAndMore2);
- CreatePeerConnection(kTurnIceServerUri, kTurnPassword, NULL);
+ CreatePeerConnectionWithIceServer(kTurnIceServerUri, kTurnPassword);
EXPECT_EQ(0u, port_allocator_->stun_servers().size());
EXPECT_EQ(1u, port_allocator_->turn_servers().size());
EXPECT_EQ(kTurnUsername,
@@ -995,6 +1004,44 @@ TEST_F(PeerConnectionInterfaceTest,
CreatePeerConnectionWithDifferentConfigurations();
}
+TEST_F(PeerConnectionInterfaceTest,
+ CreatePeerConnectionWithDifferentIceTransportsTypes) {
+ CreatePeerConnectionWithIceTransportsType(PeerConnectionInterface::kNone);
+ EXPECT_EQ(cricket::CF_NONE, port_allocator_->candidate_filter());
+ CreatePeerConnectionWithIceTransportsType(PeerConnectionInterface::kRelay);
+ EXPECT_EQ(cricket::CF_RELAY, port_allocator_->candidate_filter());
+ CreatePeerConnectionWithIceTransportsType(PeerConnectionInterface::kNoHost);
+ EXPECT_EQ(cricket::CF_ALL & ~cricket::CF_HOST,
+ port_allocator_->candidate_filter());
+ CreatePeerConnectionWithIceTransportsType(PeerConnectionInterface::kAll);
+ EXPECT_EQ(cricket::CF_ALL, port_allocator_->candidate_filter());
+}
+
+// Test that when a PeerConnection is created with a nonzero candidate pool
+// size, the pooled PortAllocatorSession is created with all the attributes
+// in the RTCConfiguration.
+TEST_F(PeerConnectionInterfaceTest, CreatePeerConnectionWithPooledCandidates) {
+ PeerConnectionInterface::RTCConfiguration config;
+ PeerConnectionInterface::IceServer server;
+ server.uri = kStunAddressOnly;
+ config.servers.push_back(server);
+ config.type = PeerConnectionInterface::kRelay;
+ config.disable_ipv6 = true;
+ config.tcp_candidate_policy =
+ PeerConnectionInterface::kTcpCandidatePolicyDisabled;
+ config.ice_candidate_pool_size = 1;
+ CreatePeerConnection(config, nullptr);
+
+ const cricket::FakePortAllocatorSession* session =
+ static_cast<const cricket::FakePortAllocatorSession*>(
+ port_allocator_->GetPooledSession());
+ ASSERT_NE(nullptr, session);
+ EXPECT_EQ(1UL, session->stun_servers().size());
+ EXPECT_EQ(0U, session->flags() & cricket::PORTALLOCATOR_ENABLE_IPV6);
+ EXPECT_LT(0U, session->flags() & cricket::PORTALLOCATOR_DISABLE_TCP);
+ EXPECT_EQ(cricket::CF_RELAY, session->candidate_filter());
+}
+
TEST_F(PeerConnectionInterfaceTest, AddStreams) {
CreatePeerConnection();
AddVideoStream(kStreamLabel1);
@@ -1888,6 +1935,35 @@ TEST_F(PeerConnectionInterfaceTest, SetConfigurationChangesIceServers) {
port_allocator_->stun_servers().begin()->hostname());
}
+TEST_F(PeerConnectionInterfaceTest, SetConfigurationChangesCandidateFilter) {
+ CreatePeerConnection();
+ PeerConnectionInterface::RTCConfiguration config;
+ config.type = PeerConnectionInterface::kRelay;
+ EXPECT_TRUE(pc_->SetConfiguration(config));
+ EXPECT_EQ(cricket::CF_RELAY, port_allocator_->candidate_filter());
+}
+
+// Test that when SetConfiguration changes both the pool size and other
+// attributes, the pooled session is created with the updated attributes.
+TEST_F(PeerConnectionInterfaceTest,
+ SetConfigurationCreatesPooledSessionCorrectly) {
+ CreatePeerConnection();
+ PeerConnectionInterface::RTCConfiguration config;
+ config.ice_candidate_pool_size = 1;
+ PeerConnectionInterface::IceServer server;
+ server.uri = kStunAddressOnly;
+ config.servers.push_back(server);
+ config.type = PeerConnectionInterface::kRelay;
+ CreatePeerConnection(config, nullptr);
+
+ const cricket::FakePortAllocatorSession* session =
+ static_cast<const cricket::FakePortAllocatorSession*>(
+ port_allocator_->GetPooledSession());
+ ASSERT_NE(nullptr, session);
+ EXPECT_EQ(1UL, session->stun_servers().size());
+ EXPECT_EQ(cricket::CF_RELAY, session->candidate_filter());
+}
+
// Test that PeerConnection::Close changes the states to closed and all remote
// tracks change state to ended.
TEST_F(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) {
« 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