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

Side by Side Diff: webrtc/p2p/client/basicportallocator_unittest.cc

Issue 2261523004: Signal to remove remote candidates if ports are pruned. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: inline set_pruned method Created 4 years, 3 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 /* 1 /*
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2009 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 const std::string& ice_ufrag, 236 const std::string& ice_ufrag,
237 const std::string& ice_pwd) { 237 const std::string& ice_pwd) {
238 std::unique_ptr<PortAllocatorSession> session = 238 std::unique_ptr<PortAllocatorSession> session =
239 allocator_->CreateSession(content_name, component, ice_ufrag, ice_pwd); 239 allocator_->CreateSession(content_name, component, ice_ufrag, ice_pwd);
240 session->SignalPortReady.connect(this, 240 session->SignalPortReady.connect(this,
241 &BasicPortAllocatorTest::OnPortReady); 241 &BasicPortAllocatorTest::OnPortReady);
242 session->SignalPortsPruned.connect(this, 242 session->SignalPortsPruned.connect(this,
243 &BasicPortAllocatorTest::OnPortsPruned); 243 &BasicPortAllocatorTest::OnPortsPruned);
244 session->SignalCandidatesReady.connect( 244 session->SignalCandidatesReady.connect(
245 this, &BasicPortAllocatorTest::OnCandidatesReady); 245 this, &BasicPortAllocatorTest::OnCandidatesReady);
246 session->SignalCandidatesRemoved.connect(
247 this, &BasicPortAllocatorTest::OnCandidatesRemoved);
246 session->SignalCandidatesAllocationDone.connect( 248 session->SignalCandidatesAllocationDone.connect(
247 this, &BasicPortAllocatorTest::OnCandidatesAllocationDone); 249 this, &BasicPortAllocatorTest::OnCandidatesAllocationDone);
248 return session; 250 return session;
249 } 251 }
250 252
251 // Return true if the addresses are the same, or the port is 0 in |pattern| 253 // Return true if the addresses are the same, or the port is 0 in |pattern|
252 // (acting as a wildcard) and the IPs are the same. 254 // (acting as a wildcard) and the IPs are the same.
253 // Even with a wildcard port, the port of the address should be nonzero if 255 // Even with a wildcard port, the port of the address should be nonzero if
254 // the IP is nonzero. 256 // the IP is nonzero.
255 static bool AddressMatch(const SocketAddress& address, 257 static bool AddressMatch(const SocketAddress& address,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp", 399 EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp",
398 rtc::SocketAddress(relay_candidate_tcp_transport_addr, 0), 400 rtc::SocketAddress(relay_candidate_tcp_transport_addr, 0),
399 rtc::SocketAddress(stun_candidate_addr, 0)); 401 rtc::SocketAddress(stun_candidate_addr, 0));
400 ++total_candidates; 402 ++total_candidates;
401 } 403 }
402 404
403 EXPECT_EQ(total_candidates, candidates_.size()); 405 EXPECT_EQ(total_candidates, candidates_.size());
404 EXPECT_EQ(total_ports, ports_.size()); 406 EXPECT_EQ(total_ports, ports_.size());
405 } 407 }
406 408
409 rtc::VirtualSocketServer* virtual_socket_server() { return vss_.get(); }
410
407 protected: 411 protected:
408 BasicPortAllocator& allocator() { return *allocator_; } 412 BasicPortAllocator& allocator() { return *allocator_; }
409 413
410 void OnPortReady(PortAllocatorSession* ses, PortInterface* port) { 414 void OnPortReady(PortAllocatorSession* ses, PortInterface* port) {
411 LOG(LS_INFO) << "OnPortReady: " << port->ToString(); 415 LOG(LS_INFO) << "OnPortReady: " << port->ToString();
412 ports_.push_back(port); 416 ports_.push_back(port);
413 // Make sure the new port is added to ReadyPorts. 417 // Make sure the new port is added to ReadyPorts.
414 auto ready_ports = ses->ReadyPorts(); 418 auto ready_ports = ses->ReadyPorts();
415 EXPECT_NE(ready_ports.end(), 419 EXPECT_NE(ready_ports.end(),
416 std::find(ready_ports.begin(), ready_ports.end(), port)); 420 std::find(ready_ports.begin(), ready_ports.end(), port));
(...skipping 22 matching lines...) Expand all
439 } 443 }
440 // Make sure the new candidates are added to Candidates. 444 // Make sure the new candidates are added to Candidates.
441 auto ses_candidates = ses->ReadyCandidates(); 445 auto ses_candidates = ses->ReadyCandidates();
442 for (const Candidate& candidate : candidates) { 446 for (const Candidate& candidate : candidates) {
443 EXPECT_NE( 447 EXPECT_NE(
444 ses_candidates.end(), 448 ses_candidates.end(),
445 std::find(ses_candidates.begin(), ses_candidates.end(), candidate)); 449 std::find(ses_candidates.begin(), ses_candidates.end(), candidate));
446 } 450 }
447 } 451 }
448 452
453 void OnCandidatesRemoved(PortAllocatorSession* session,
454 const std::vector<Candidate>& removed_candidates) {
455 auto new_end = std::remove_if(
456 candidates_.begin(), candidates_.end(),
457 [removed_candidates](Candidate& candidate) {
458 for (const Candidate& removed_candidate : removed_candidates) {
459 if (candidate.MatchesForRemoval(removed_candidate)) {
460 return true;
461 }
462 }
463 return false;
464 });
465 candidates_.erase(new_end, candidates_.end());
466 }
467
449 bool HasRelayAddress(const ProtocolAddress& proto_addr) { 468 bool HasRelayAddress(const ProtocolAddress& proto_addr) {
450 for (size_t i = 0; i < allocator_->turn_servers().size(); ++i) { 469 for (size_t i = 0; i < allocator_->turn_servers().size(); ++i) {
451 RelayServerConfig server_config = allocator_->turn_servers()[i]; 470 RelayServerConfig server_config = allocator_->turn_servers()[i];
452 PortList::const_iterator relay_port; 471 PortList::const_iterator relay_port;
453 for (relay_port = server_config.ports.begin(); 472 for (relay_port = server_config.ports.begin();
454 relay_port != server_config.ports.end(); ++relay_port) { 473 relay_port != server_config.ports.end(); ++relay_port) {
455 if (proto_addr.address == relay_port->address && 474 if (proto_addr.address == relay_port->address &&
456 proto_addr.proto == relay_port->proto) 475 proto_addr.proto == relay_port->proto)
457 return true; 476 return true;
458 } 477 }
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); 1226 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
1208 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", 1227 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp",
1209 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); 1228 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
1210 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); 1229 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
1211 EXPECT_EQ(3U, candidates_.size()); 1230 EXPECT_EQ(3U, candidates_.size());
1212 } 1231 }
1213 1232
1214 // Test that if prune_turn_ports is set, TCP TurnPort will not 1233 // Test that if prune_turn_ports is set, TCP TurnPort will not
1215 // be used if UDP TurnPort is used. 1234 // be used if UDP TurnPort is used.
1216 TEST_F(BasicPortAllocatorTest, TestUdpTurnPortPrunesTcpTurnPorts) { 1235 TEST_F(BasicPortAllocatorTest, TestUdpTurnPortPrunesTcpTurnPorts) {
1236 // Using a large standard deviation for the transit delay so that TCP Turn
1237 // ports may become ready sometimes before the UDP Turn port does,
1238 // and sometimes after that.
1239 // TODO(honghaiz): Change the virtual socket to tell if it is UDP or TCP, so
1240 // that we can control the TCP delay independently of the UDP delay.
Taylor Brandstetter 2016/09/15 00:43:17 Since IPv4 vs. IPv6 is already handled in this CL,
honghaiz3 2016/09/16 01:41:30 Done.
1241 virtual_socket_server()->set_delay_mean(50);
1242 virtual_socket_server()->set_delay_stddev(200);
1243 virtual_socket_server()->UpdateDelayDistribution();
1244
1217 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); 1245 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP);
1218 AddInterface(kClientAddr); 1246 AddInterface(kClientAddr);
1219 allocator_.reset(new BasicPortAllocator(&network_manager_)); 1247 allocator_.reset(new BasicPortAllocator(&network_manager_));
1220 allocator_->SetConfiguration(allocator_->stun_servers(), 1248 allocator_->SetConfiguration(allocator_->stun_servers(),
1221 allocator_->turn_servers(), 0, true); 1249 allocator_->turn_servers(), 0, true);
1222 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); 1250 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr);
1223 allocator_->set_step_delay(kMinimumStepDelay); 1251 allocator_->set_step_delay(kMinimumStepDelay);
1224 allocator_->set_flags(allocator().flags() | 1252 allocator_->set_flags(allocator().flags() |
1225 PORTALLOCATOR_ENABLE_SHARED_SOCKET | 1253 PORTALLOCATOR_ENABLE_SHARED_SOCKET |
1226 PORTALLOCATOR_DISABLE_TCP); 1254 PORTALLOCATOR_DISABLE_TCP);
1227 1255
1228 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); 1256 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP));
1229 session_->StartGettingPorts(); 1257 session_->StartGettingPorts();
1230 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); 1258 EXPECT_TRUE_WAIT(candidate_allocation_done_, 10000);
Taylor Brandstetter 2016/09/15 00:43:17 nit: May want to use a constant for this timeout.
honghaiz3 2016/09/16 01:41:30 Done. Now that there is no randomness, I don't thi
1231 // Only 2 ports (one STUN and one TURN) are actually being used. 1259 // Only 2 ports (one STUN and one TURN) are actually being used.
1232 EXPECT_EQ(2U, session_->ReadyPorts().size()); 1260 EXPECT_EQ(2U, session_->ReadyPorts().size());
1233 // We have verified that each port, when it is added to |ports_|, it is found 1261 // We have verified that each port, when it is added to |ports_|, it is found
1234 // in |ready_ports|, and when it is pruned, it is not found in |ready_ports|, 1262 // in |ready_ports|, and when it is pruned, it is not found in |ready_ports|,
1235 // so we only need to verify the content in one of them. 1263 // so we only need to verify the content in one of them.
1236 EXPECT_EQ(2U, ports_.size()); 1264 EXPECT_EQ(2U, ports_.size());
1237 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr)); 1265 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr));
1238 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kClientAddr)); 1266 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kClientAddr));
1239 EXPECT_EQ(0, CountPorts(ports_, "relay", PROTO_TCP, kClientAddr)); 1267 EXPECT_EQ(0, CountPorts(ports_, "relay", PROTO_TCP, kClientAddr));
1240 1268
1241 // We don't remove candidates, so the size of |candidates_| will depend on 1269 // Now that we remove candidates when a Turn port is pruned, |candidates_|
1242 // when the TCP TURN port becomes ready. If it is ready after the UDP TURN 1270 // should only contains two candidates regardless whether the TCP Turn port is
1243 // port becomes ready, its candidates will be used there will be 3 candidates. 1271 // created before or after the UDP turn port.
Taylor Brandstetter 2016/09/15 00:43:17 nit: Capitalize "TURN"
honghaiz3 2016/09/16 01:41:30 Done.
1244 // Otherwise there will be only 2 candidates. 1272 EXPECT_EQ(2U, candidates_.size());
1245 EXPECT_LE(2U, candidates_.size());
1246 // There will only be 2 candidates in |ready_candidates| because it only 1273 // There will only be 2 candidates in |ready_candidates| because it only
1247 // includes the candidates in the ready ports. 1274 // includes the candidates in the ready ports.
1248 const std::vector<Candidate>& ready_candidates = session_->ReadyCandidates(); 1275 const std::vector<Candidate>& ready_candidates = session_->ReadyCandidates();
1249 EXPECT_EQ(2U, ready_candidates.size()); 1276 EXPECT_EQ(2U, ready_candidates.size());
1250 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr); 1277 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr);
1251 EXPECT_PRED4(HasCandidate, ready_candidates, "relay", "udp", 1278 EXPECT_PRED4(HasCandidate, ready_candidates, "relay", "udp",
1252 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); 1279 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
1253 } 1280 }
1254 1281
1255 // Tests that if prune_turn_ports is set, IPv4 TurnPort will not 1282 // Tests that if prune_turn_ports is set, IPv4 TurnPort will not
1256 // be used if IPv6 TurnPort is used. 1283 // be used if IPv6 TurnPort is used.
1257 TEST_F(BasicPortAllocatorTest, TestIPv6TurnPortPrunesIPv4TurnPorts) { 1284 TEST_F(BasicPortAllocatorTest, TestIPv6TurnPortPrunesIPv4TurnPorts) {
1285 // Make the mean IPv6 delay longer than the mean IPv4 delay so that it is
1286 // more likely that the IPv4 candidates are initially generated and then
1287 // removed.
1288 virtual_socket_server()->set_delay_stddev(100);
Taylor Brandstetter 2016/09/15 00:43:17 Since you can control the delay for IPv6 vs. IPv4
honghaiz3 2016/09/16 01:41:30 I was hoping to use a random value to test behavio
1289 virtual_socket_server()->set_delay_mean(100);
1290 virtual_socket_server()->UpdateDelayDistribution();
1291 virtual_socket_server()->set_delay_mean(200);
1292 virtual_socket_server()->UpdateDelayDistributionForIPv6();
1293
1258 turn_server_.AddInternalSocket(kTurnUdpIntIPv6Addr, PROTO_UDP); 1294 turn_server_.AddInternalSocket(kTurnUdpIntIPv6Addr, PROTO_UDP);
1259 // Add two IP addresses on the same interface. 1295 // Add two IP addresses on the same interface.
1260 AddInterface(kClientAddr, "net1"); 1296 AddInterface(kClientAddr, "net1");
1261 AddInterface(kClientIPv6Addr, "net1"); 1297 AddInterface(kClientIPv6Addr, "net1");
1262 allocator_.reset(new BasicPortAllocator(&network_manager_)); 1298 allocator_.reset(new BasicPortAllocator(&network_manager_));
1263 allocator_->SetConfiguration(allocator_->stun_servers(), 1299 allocator_->SetConfiguration(allocator_->stun_servers(),
1264 allocator_->turn_servers(), 0, true); 1300 allocator_->turn_servers(), 0, true);
1265 AddTurnServers(kTurnUdpIntIPv6Addr, rtc::SocketAddress()); 1301 AddTurnServers(kTurnUdpIntIPv6Addr, rtc::SocketAddress());
1302 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress());
1266 1303
1267 allocator_->set_step_delay(kMinimumStepDelay); 1304 allocator_->set_step_delay(kMinimumStepDelay);
1268 allocator_->set_flags(allocator().flags() | 1305 allocator_->set_flags(allocator().flags() |
1269 PORTALLOCATOR_ENABLE_SHARED_SOCKET | 1306 PORTALLOCATOR_ENABLE_SHARED_SOCKET |
1270 PORTALLOCATOR_ENABLE_IPV6 | PORTALLOCATOR_DISABLE_TCP); 1307 PORTALLOCATOR_ENABLE_IPV6 | PORTALLOCATOR_DISABLE_TCP);
1271 1308
1272 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); 1309 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP));
1273 session_->StartGettingPorts(); 1310 session_->StartGettingPorts();
1274 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); 1311 EXPECT_TRUE_WAIT(candidate_allocation_done_, 10000);
1275 // Three ports (one IPv4 STUN, one IPv6 STUN and one TURN) will be ready. 1312 // Three ports (one IPv4 STUN, one IPv6 STUN and one TURN) will be ready.
1276 EXPECT_EQ(3U, session_->ReadyPorts().size()); 1313 EXPECT_EQ(3U, session_->ReadyPorts().size());
1277 EXPECT_EQ(3U, ports_.size()); 1314 EXPECT_EQ(3U, ports_.size());
1278 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr)); 1315 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr));
1279 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientIPv6Addr)); 1316 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientIPv6Addr));
1280 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kClientIPv6Addr)); 1317 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kClientIPv6Addr));
1281 EXPECT_EQ(0, CountPorts(ports_, "relay", PROTO_UDP, kClientAddr)); 1318 EXPECT_EQ(0, CountPorts(ports_, "relay", PROTO_UDP, kClientAddr));
1282 1319
1283 // We don't remove candidates, so there may be more than 3 elemenets in 1320 // Now that we remove candidates when a Turn port is pruned, there will be
1284 // |candidates_|, although |ready_candidates| only includes the candidates 1321 // exactly 3 candidates in both |candidates_| and |ready_candidates|.
1285 // in |ready_ports|. 1322 EXPECT_EQ(3U, candidates_.size());
1286 EXPECT_LE(3U, candidates_.size());
1287 const std::vector<Candidate>& ready_candidates = session_->ReadyCandidates(); 1323 const std::vector<Candidate>& ready_candidates = session_->ReadyCandidates();
1288 EXPECT_EQ(3U, ready_candidates.size()); 1324 EXPECT_EQ(3U, ready_candidates.size());
1289 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr); 1325 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr);
1290 EXPECT_PRED4(HasCandidate, ready_candidates, "relay", "udp", 1326 EXPECT_PRED4(HasCandidate, ready_candidates, "relay", "udp",
1291 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); 1327 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
1292 } 1328 }
1293 1329
1294 // Tests that if prune_turn_ports is set, each network interface 1330 // Tests that if prune_turn_ports is set, each network interface
1295 // will has its own set of TurnPorts based on their priorities. 1331 // will has its own set of TurnPorts based on their priorities.
1296 TEST_F(BasicPortAllocatorTest, TestEachInterfaceHasItsOwnTurnPorts) { 1332 TEST_F(BasicPortAllocatorTest, TestEachInterfaceHasItsOwnTurnPorts) {
1333 // Make IPv6 sockets have longer delay than IPv4 sockets so that it has
1334 // higher chance that IPv4 candidates are generated and then removed.
1335 virtual_socket_server()->set_delay_stddev(100);
1336 virtual_socket_server()->set_delay_mean(100);
1337 virtual_socket_server()->UpdateDelayDistribution();
1338 virtual_socket_server()->set_delay_mean(200);
1339 virtual_socket_server()->UpdateDelayDistributionForIPv6();
1340
1297 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); 1341 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP);
1298 turn_server_.AddInternalSocket(kTurnUdpIntIPv6Addr, PROTO_UDP); 1342 turn_server_.AddInternalSocket(kTurnUdpIntIPv6Addr, PROTO_UDP);
1299 turn_server_.AddInternalSocket(kTurnTcpIntIPv6Addr, PROTO_TCP); 1343 turn_server_.AddInternalSocket(kTurnTcpIntIPv6Addr, PROTO_TCP);
1300 // Add two interfaces both having IPv4 and IPv6 addresses. 1344 // Add two interfaces both having IPv4 and IPv6 addresses.
1301 AddInterface(kClientAddr, "net1", rtc::ADAPTER_TYPE_WIFI); 1345 AddInterface(kClientAddr, "net1", rtc::ADAPTER_TYPE_WIFI);
1302 AddInterface(kClientIPv6Addr, "net1", rtc::ADAPTER_TYPE_WIFI); 1346 AddInterface(kClientIPv6Addr, "net1", rtc::ADAPTER_TYPE_WIFI);
1303 AddInterface(kClientAddr2, "net2", rtc::ADAPTER_TYPE_CELLULAR); 1347 AddInterface(kClientAddr2, "net2", rtc::ADAPTER_TYPE_CELLULAR);
1304 AddInterface(kClientIPv6Addr2, "net2", rtc::ADAPTER_TYPE_CELLULAR); 1348 AddInterface(kClientIPv6Addr2, "net2", rtc::ADAPTER_TYPE_CELLULAR);
1305 allocator_.reset(new BasicPortAllocator(&network_manager_)); 1349 allocator_.reset(new BasicPortAllocator(&network_manager_));
1306 allocator_->SetConfiguration(allocator_->stun_servers(), 1350 allocator_->SetConfiguration(allocator_->stun_servers(),
1307 allocator_->turn_servers(), 0, true); 1351 allocator_->turn_servers(), 0, true);
1308 // Have both UDP/TCP and IPv4/IPv6 TURN ports. 1352 // Have both UDP/TCP and IPv4/IPv6 TURN ports.
1309 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); 1353 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr);
1310 AddTurnServers(kTurnUdpIntIPv6Addr, kTurnTcpIntIPv6Addr); 1354 AddTurnServers(kTurnUdpIntIPv6Addr, kTurnTcpIntIPv6Addr);
1311 1355
1312 allocator_->set_step_delay(kMinimumStepDelay); 1356 allocator_->set_step_delay(kMinimumStepDelay);
1313 allocator_->set_flags(allocator().flags() | 1357 allocator_->set_flags(allocator().flags() |
1314 PORTALLOCATOR_ENABLE_SHARED_SOCKET | 1358 PORTALLOCATOR_ENABLE_SHARED_SOCKET |
1315 PORTALLOCATOR_ENABLE_IPV6); 1359 PORTALLOCATOR_ENABLE_IPV6);
1316 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); 1360 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP));
1317 session_->StartGettingPorts(); 1361 session_->StartGettingPorts();
1318 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); 1362 EXPECT_TRUE_WAIT(candidate_allocation_done_, 10000);
1319 // 10 ports (4 STUN and 1 TURN ports on each interface) will be ready to use. 1363 // 10 ports (4 STUN and 1 TURN ports on each interface) will be ready to use.
1320 EXPECT_EQ(10U, session_->ReadyPorts().size()); 1364 EXPECT_EQ(10U, session_->ReadyPorts().size());
1321 EXPECT_EQ(10U, ports_.size()); 1365 EXPECT_EQ(10U, ports_.size());
1322 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr)); 1366 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr));
1323 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr2)); 1367 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr2));
1324 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientIPv6Addr)); 1368 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientIPv6Addr));
1325 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientIPv6Addr2)); 1369 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientIPv6Addr2));
1326 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_TCP, kClientAddr)); 1370 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_TCP, kClientAddr));
1327 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_TCP, kClientAddr2)); 1371 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_TCP, kClientAddr2));
1328 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_TCP, kClientIPv6Addr)); 1372 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_TCP, kClientIPv6Addr));
1329 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_TCP, kClientIPv6Addr2)); 1373 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_TCP, kClientIPv6Addr2));
1330 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kClientIPv6Addr)); 1374 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kClientIPv6Addr));
1331 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kClientIPv6Addr2)); 1375 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kClientIPv6Addr2));
1332 1376
1333 // We don't remove candidates, so there may be more than 10 candidates 1377 // Now that we remove candidates when Turn ports are pruned, there will be
1334 // in |candidates_|. 1378 // exactly 10 candidates in |candidates_|.
1335 EXPECT_LE(10U, candidates_.size()); 1379 EXPECT_EQ(10U, candidates_.size());
1336 const std::vector<Candidate>& ready_candidates = session_->ReadyCandidates(); 1380 const std::vector<Candidate>& ready_candidates = session_->ReadyCandidates();
1337 EXPECT_EQ(10U, ready_candidates.size()); 1381 EXPECT_EQ(10U, ready_candidates.size());
1338 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr); 1382 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr);
1339 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr2); 1383 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr2);
1340 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientIPv6Addr); 1384 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientIPv6Addr);
1341 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", 1385 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp",
1342 kClientIPv6Addr2); 1386 kClientIPv6Addr2);
1343 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", kClientAddr); 1387 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", kClientAddr);
1344 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", kClientAddr2); 1388 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", kClientAddr2);
1345 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", kClientIPv6Addr); 1389 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", kClientIPv6Addr);
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 for (const Candidate& candidate : candidates) { 1751 for (const Candidate& candidate : candidates) {
1708 // Expect only relay candidates now that the filter is applied. 1752 // Expect only relay candidates now that the filter is applied.
1709 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); 1753 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type());
1710 // Expect that the raddr is emptied due to the CF_RELAY filter. 1754 // Expect that the raddr is emptied due to the CF_RELAY filter.
1711 EXPECT_EQ(candidate.related_address(), 1755 EXPECT_EQ(candidate.related_address(),
1712 rtc::EmptySocketAddressWithFamily(candidate.address().family())); 1756 rtc::EmptySocketAddressWithFamily(candidate.address().family()));
1713 } 1757 }
1714 } 1758 }
1715 1759
1716 } // namespace cricket 1760 } // namespace cricket
OLDNEW
« webrtc/p2p/client/basicportallocator.cc ('K') | « webrtc/p2p/client/basicportallocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698