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

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

Issue 1411253008: WebRTC should generate default private address even when adapter enumeration is disabled. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: after rebase on master Created 5 years, 1 month 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/p2p/client/basicportallocator.cc ('k') | no next file » | 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 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 kRelayUdpIntAddr, kRelayTcpIntAddr, kRelaySslTcpIntAddr)); 107 kRelayUdpIntAddr, kRelayTcpIntAddr, kRelaySslTcpIntAddr));
108 allocator_->set_step_delay(cricket::kMinimumStepDelay); 108 allocator_->set_step_delay(cricket::kMinimumStepDelay);
109 } 109 }
110 110
111 void AddInterface(const SocketAddress& addr) { 111 void AddInterface(const SocketAddress& addr) {
112 network_manager_.AddInterface(addr); 112 network_manager_.AddInterface(addr);
113 } 113 }
114 void AddInterface(const SocketAddress& addr, const std::string& if_name) { 114 void AddInterface(const SocketAddress& addr, const std::string& if_name) {
115 network_manager_.AddInterface(addr, if_name); 115 network_manager_.AddInterface(addr, if_name);
116 } 116 }
117 // The default route is the public address that STUN server will observe when
118 // the endpoint is sitting on the public internet and the local port is bound
119 // to the "any" address. This may be different from the default local address
120 // which the endpoint observes. This can occur if the route to the public
121 // endpoint like 8.8.8.8 (specified as the default local address) is
122 // different from the route to the STUN server (the default route).
117 void AddInterfaceAsDefaultRoute(const SocketAddress& addr) { 123 void AddInterfaceAsDefaultRoute(const SocketAddress& addr) {
118 AddInterface(addr); 124 AddInterface(addr);
119 // When a binding comes from the any address, the |addr| will be used as the 125 // When a binding comes from the any address, the |addr| will be used as the
120 // srflx address. 126 // srflx address.
121 vss_->SetDefaultRoute(addr.ipaddr()); 127 vss_->SetDefaultRoute(addr.ipaddr());
122 } 128 }
123 void RemoveInterface(const SocketAddress& addr) { 129 void RemoveInterface(const SocketAddress& addr) {
124 network_manager_.RemoveInterface(addr); 130 network_manager_.RemoveInterface(addr);
125 } 131 }
126 bool SetPortRange(int min_port, int max_port) { 132 bool SetPortRange(int min_port, int max_port) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // candidates as specified. When |expect_stun_candidate| is true, 253 // candidates as specified. When |expect_stun_candidate| is true,
248 // |stun_candidate_addr| carries the expected reflective address, which is 254 // |stun_candidate_addr| carries the expected reflective address, which is
249 // also the related address for TURN candidate if it is expected. Otherwise, 255 // also the related address for TURN candidate if it is expected. Otherwise,
250 // it should be ignore. 256 // it should be ignore.
251 void CheckDisableAdapterEnumeration( 257 void CheckDisableAdapterEnumeration(
252 uint32_t total_ports, 258 uint32_t total_ports,
253 const rtc::IPAddress& host_candidate_addr, 259 const rtc::IPAddress& host_candidate_addr,
254 const rtc::IPAddress& stun_candidate_addr, 260 const rtc::IPAddress& stun_candidate_addr,
255 const rtc::IPAddress& relay_candidate_udp_transport_addr, 261 const rtc::IPAddress& relay_candidate_udp_transport_addr,
256 const rtc::IPAddress& relay_candidate_tcp_transport_addr) { 262 const rtc::IPAddress& relay_candidate_tcp_transport_addr) {
263 network_manager_.set_default_local_addresses(kPrivateAddr.ipaddr(),
264 rtc::IPAddress());
257 if (!session_) { 265 if (!session_) {
258 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 266 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
259 } 267 }
260 session_->set_flags(session_->flags() | 268 session_->set_flags(session_->flags() |
261 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION | 269 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION |
262 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); 270 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
263 allocator().set_allow_tcp_listen(false); 271 allocator().set_allow_tcp_listen(false);
264 session_->StartGettingPorts(); 272 session_->StartGettingPorts();
265 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); 273 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
266 274
267 uint32_t total_candidates = 0; 275 uint32_t total_candidates = 0;
268 if (!host_candidate_addr.IsNil()) { 276 if (!host_candidate_addr.IsNil()) {
269 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates], 277 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates],
270 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", 278 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp",
271 rtc::SocketAddress(host_candidate_addr, 0)); 279 rtc::SocketAddress(kPrivateAddr.ipaddr(), 0));
272 ++total_candidates; 280 ++total_candidates;
273 } 281 }
274 if (!stun_candidate_addr.IsNil()) { 282 if (!stun_candidate_addr.IsNil()) {
275 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates], 283 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates],
276 cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", 284 cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp",
277 rtc::SocketAddress(stun_candidate_addr, 0)); 285 rtc::SocketAddress(stun_candidate_addr, 0));
278 EXPECT_EQ(rtc::EmptySocketAddressWithFamily( 286 rtc::IPAddress related_address = host_candidate_addr;
279 candidates_[total_candidates].address().family()), 287 if (host_candidate_addr.IsNil()) {
280 candidates_[total_candidates].related_address()); 288 related_address =
289 rtc::GetAnyIP(candidates_[total_candidates].address().family());
290 }
291 EXPECT_EQ(related_address,
292 candidates_[total_candidates].related_address().ipaddr());
281 ++total_candidates; 293 ++total_candidates;
282 } 294 }
283 if (!relay_candidate_udp_transport_addr.IsNil()) { 295 if (!relay_candidate_udp_transport_addr.IsNil()) {
284 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates], 296 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates],
285 cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp", 297 cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp",
286 rtc::SocketAddress(relay_candidate_udp_transport_addr, 0)); 298 rtc::SocketAddress(relay_candidate_udp_transport_addr, 0));
287 EXPECT_EQ(stun_candidate_addr, 299 EXPECT_EQ(stun_candidate_addr,
288 candidates_[total_candidates].related_address().ipaddr()); 300 candidates_[total_candidates].related_address().ipaddr());
289 ++total_candidates; 301 ++total_candidates;
290 } 302 }
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 rtc::Thread::Current()->ProcessMessages(100); 594 rtc::Thread::Current()->ProcessMessages(100);
583 // Without network adapter, we should not get any candidate. 595 // Without network adapter, we should not get any candidate.
584 EXPECT_EQ(0U, candidates_.size()); 596 EXPECT_EQ(0U, candidates_.size());
585 EXPECT_TRUE(candidate_allocation_done_); 597 EXPECT_TRUE(candidate_allocation_done_);
586 } 598 }
587 599
588 // Test that when enumeration is disabled, we should not have any ports when 600 // Test that when enumeration is disabled, we should not have any ports when
589 // candidate_filter() is set to CF_RELAY and no relay is specified. 601 // candidate_filter() is set to CF_RELAY and no relay is specified.
590 TEST_F(PortAllocatorTest, 602 TEST_F(PortAllocatorTest,
591 TestDisableAdapterEnumerationWithoutNatRelayTransportOnly) { 603 TestDisableAdapterEnumerationWithoutNatRelayTransportOnly) {
592 AddInterfaceAsDefaultRoute(kClientAddr);
593 ResetWithStunServerNoNat(kStunAddr); 604 ResetWithStunServerNoNat(kStunAddr);
594 allocator().set_candidate_filter(cricket::CF_RELAY); 605 allocator().set_candidate_filter(cricket::CF_RELAY);
595 // Expect to see no ports and no candidates. 606 // Expect to see no ports and no candidates.
596 CheckDisableAdapterEnumeration(0U, rtc::IPAddress(), rtc::IPAddress(), 607 CheckDisableAdapterEnumeration(0U, rtc::IPAddress(), rtc::IPAddress(),
597 rtc::IPAddress(), rtc::IPAddress()); 608 rtc::IPAddress(), rtc::IPAddress());
598 } 609 }
599 610
600 // Test that we should only get STUN and TURN candidates when adapter 611 // Test that even with multiple interfaces, the result should still be a single
601 // enumeration is disabled. 612 // default private, one STUN and one TURN candidate since we bind to any address
602 TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationBehindNat) { 613 // (i.e. all 0s).
603 AddInterface(kClientAddr);
604 // GTURN is not configured here.
605 ResetWithStunServerAndNat(kStunAddr);
606 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress());
607 // Expect to see 3 ports: STUN, TURN/UDP and TCP ports, and both STUN and
608 // TURN/UDP candidates.
609 CheckDisableAdapterEnumeration(3U, rtc::IPAddress(), kNatUdpAddr.ipaddr(),
610 kTurnUdpExtAddr.ipaddr(), rtc::IPAddress());
611 }
612
613 // Test that even with multiple interfaces, the result should still be one STUN
614 // and one TURN candidate since we bind to any address (i.e. all 0s).
615 TEST_F(PortAllocatorTest, 614 TEST_F(PortAllocatorTest,
616 TestDisableAdapterEnumerationBehindNatMultipleInterfaces) { 615 TestDisableAdapterEnumerationBehindNatMultipleInterfaces) {
617 AddInterface(kPrivateAddr); 616 AddInterface(kPrivateAddr);
618 AddInterface(kPrivateAddr2); 617 AddInterface(kPrivateAddr2);
619 ResetWithStunServerAndNat(kStunAddr); 618 ResetWithStunServerAndNat(kStunAddr);
620 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); 619 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress());
621 // Expect to see 3 ports: STUN, TURN/UDP and TCP ports, and both STUN and 620 // Expect to see 3 ports: STUN, TURN/UDP and TCP ports, and a default private,
622 // TURN/UDP candidates. 621 // STUN and TURN/UDP candidates.
623 CheckDisableAdapterEnumeration(3U, rtc::IPAddress(), kNatUdpAddr.ipaddr(), 622 CheckDisableAdapterEnumeration(3U, kPrivateAddr.ipaddr(),
624 kTurnUdpExtAddr.ipaddr(), rtc::IPAddress()); 623 kNatUdpAddr.ipaddr(), kTurnUdpExtAddr.ipaddr(),
624 rtc::IPAddress());
625 } 625 }
626 626
627 // Test that we should get STUN, TURN/UDP and TURN/TCP candidates when a 627 // Test that we should get a default private, STUN, TURN/UDP and TURN/TCP
628 // TURN/TCP server is specified. 628 // candidates when both TURN/UDP and TURN/TCP servers are specified.
629 TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationBehindNatWithTcp) { 629 TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationBehindNatWithTcp) {
630 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); 630 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP);
631 AddInterface(kClientAddr); 631 AddInterface(kPrivateAddr);
632 // GTURN is not configured here.
633 ResetWithStunServerAndNat(kStunAddr); 632 ResetWithStunServerAndNat(kStunAddr);
634 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); 633 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr);
635 // Expect to see 4 ports - STUN, TURN/UDP, TURN/TCP and TCP port. STUN, 634 // Expect to see 4 ports - STUN, TURN/UDP, TURN/TCP and TCP port. A default
636 // TURN/UDP, and TURN/TCP candidates. 635 // private, STUN, TURN/UDP, and TURN/TCP candidates.
637 CheckDisableAdapterEnumeration(4U, rtc::IPAddress(), kNatUdpAddr.ipaddr(), 636 CheckDisableAdapterEnumeration(4U, kPrivateAddr.ipaddr(),
638 kTurnUdpExtAddr.ipaddr(), 637 kNatUdpAddr.ipaddr(), kTurnUdpExtAddr.ipaddr(),
639 kTurnUdpExtAddr.ipaddr()); 638 kTurnUdpExtAddr.ipaddr());
640 } 639 }
641 640
642 // Test that we should only get STUN and TURN candidates when adapter 641 // Test that when adapter enumeration is disabled, for endpoints without
643 // enumeration is disabled. Since the endpoint is not behind NAT, the srflx 642 // STUN/TURN specified, a default private candidate is still generated.
644 // address should be the public client interface. 643 TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationWithoutNatOrServers) {
645 TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationWithoutNat) { 644 ResetWithNoServersOrNat();
646 AddInterfaceAsDefaultRoute(kClientAddr); 645 // Expect to see 2 ports: STUN and TCP ports, one default private candidate.
647 ResetWithStunServerNoNat(kStunAddr); 646 CheckDisableAdapterEnumeration(2U, kPrivateAddr.ipaddr(), rtc::IPAddress(),
648 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); 647 rtc::IPAddress(), rtc::IPAddress());
649 // Expect to see 3 ports: STUN, TURN/UDP and TCP ports, but only both STUN and
650 // TURN candidates. The STUN candidate should have kClientAddr as srflx
651 // address, and TURN candidate with kClientAddr as the related address.
652 CheckDisableAdapterEnumeration(3U, rtc::IPAddress(), kClientAddr.ipaddr(),
653 kTurnUdpExtAddr.ipaddr(), rtc::IPAddress());
654 } 648 }
655 649
656 // Test that when adapter enumeration is disabled, for endpoints without 650 // Test that when adapter enumeration is disabled, with
657 // STUN/TURN specified, no candidate is generated. 651 // PORTALLOCATOR_DISABLE_LOCALHOST_CANDIDATE specified, for endpoints not behind
658 TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationWithoutNatOrServers) { 652 // a NAT, there is no local candidate.
659 AddInterfaceAsDefaultRoute(kClientAddr); 653 TEST_F(PortAllocatorTest,
660 ResetWithNoServersOrNat(); 654 TestDisableAdapterEnumerationWithoutNatLocalhostCandidateDisabled) {
661 // Expect to see 2 ports: STUN and TCP ports, but no candidate. 655 ResetWithStunServerNoNat(kStunAddr);
656 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
657 session_->set_flags(cricket::PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE);
658 // Expect to see 2 ports: STUN and TCP ports, localhost candidate and STUN
659 // candidate.
662 CheckDisableAdapterEnumeration(2U, rtc::IPAddress(), rtc::IPAddress(), 660 CheckDisableAdapterEnumeration(2U, rtc::IPAddress(), rtc::IPAddress(),
663 rtc::IPAddress(), rtc::IPAddress()); 661 rtc::IPAddress(), rtc::IPAddress());
664 } 662 }
665 663
666 // Test that when adapter enumeration is disabled, with 664 // Test that when adapter enumeration is disabled, with
667 // PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE specified, for endpoints not behind 665 // PORTALLOCATOR_DISABLE_LOCALHOST_CANDIDATE specified, for endpoints not behind
668 // a NAT, there are a localhost candidate in addition to a STUN candidate. 666 // a NAT, there is no local candidate. However, this specified default route
669 TEST_F(PortAllocatorTest, 667 // (kClientAddr) which was discovered when sending STUN requests, will become
670 TestDisableAdapterEnumerationWithoutNatLocalhostCandidateRequested) { 668 // the srflx addresses.
669 TEST_F(
670 PortAllocatorTest,
671 TestDisableAdapterEnumerationWithoutNatLocalhostCandidateDisabledWithDiffere ntDefaultRoute) {
672 ResetWithStunServerNoNat(kStunAddr);
671 AddInterfaceAsDefaultRoute(kClientAddr); 673 AddInterfaceAsDefaultRoute(kClientAddr);
672 ResetWithStunServerNoNat(kStunAddr);
673 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 674 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
674 session_->set_flags(cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE); 675 session_->set_flags(cricket::PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE);
675 // Expect to see 2 ports: STUN and TCP ports, localhost candidate and STUN 676 // Expect to see 2 ports: STUN and TCP ports, localhost candidate and STUN
676 // candidate. 677 // candidate.
677 CheckDisableAdapterEnumeration(2U, rtc::GetLoopbackIP(AF_INET), 678 CheckDisableAdapterEnumeration(2U, rtc::IPAddress(), kClientAddr.ipaddr(),
678 kClientAddr.ipaddr(), rtc::IPAddress(), 679 rtc::IPAddress(), rtc::IPAddress());
679 rtc::IPAddress()); 680 }
681
682 // Test that when adapter enumeration is disabled, with
683 // PORTALLOCATOR_DISABLE_LOCALHOST_CANDIDATE specified, for endpoints behind a
684 // NAT, there is only one STUN candidate.
685 TEST_F(PortAllocatorTest,
686 TestDisableAdapterEnumerationWithNatLocalhostCandidateDisabled) {
687 ResetWithStunServerAndNat(kStunAddr);
688 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
689 session_->set_flags(cricket::PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE);
690 // Expect to see 2 ports: STUN and TCP ports, and single STUN candidate.
691 CheckDisableAdapterEnumeration(2U, rtc::IPAddress(), kNatUdpAddr.ipaddr(),
692 rtc::IPAddress(), rtc::IPAddress());
680 } 693 }
681 694
682 // Test that we disable relay over UDP, and only TCP is used when connecting to 695 // Test that we disable relay over UDP, and only TCP is used when connecting to
683 // the relay server. 696 // the relay server.
684 TEST_F(PortAllocatorTest, TestDisableUdpTurn) { 697 TEST_F(PortAllocatorTest, TestDisableUdpTurn) {
685 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); 698 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP);
686 AddInterface(kClientAddr); 699 AddInterface(kClientAddr);
687 ResetWithStunServerAndNat(kStunAddr); 700 ResetWithStunServerAndNat(kStunAddr);
688 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); 701 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr);
689 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 702 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); 1250 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr);
1238 // STUN timeout is 9sec. We need to wait to get candidate done signal. 1251 // STUN timeout is 9sec. We need to wait to get candidate done signal.
1239 EXPECT_TRUE_WAIT(candidate_allocation_done_, 10000); 1252 EXPECT_TRUE_WAIT(candidate_allocation_done_, 10000);
1240 EXPECT_EQ(1U, candidates_.size()); 1253 EXPECT_EQ(1U, candidates_.size());
1241 } 1254 }
1242 1255
1243 // Test that when the NetworkManager doesn't have permission to enumerate 1256 // Test that when the NetworkManager doesn't have permission to enumerate
1244 // adapters, the PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified 1257 // adapters, the PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified
1245 // automatically. 1258 // automatically.
1246 TEST_F(PortAllocatorTest, TestNetworkPermissionBlocked) { 1259 TEST_F(PortAllocatorTest, TestNetworkPermissionBlocked) {
1247 AddInterface(kClientAddr); 1260 network_manager_.set_default_local_addresses(kPrivateAddr.ipaddr(),
1261 rtc::IPAddress());
1248 network_manager_.set_enumeration_permission( 1262 network_manager_.set_enumeration_permission(
1249 rtc::NetworkManager::ENUMERATION_BLOCKED); 1263 rtc::NetworkManager::ENUMERATION_BLOCKED);
1250 allocator().set_flags(allocator().flags() | 1264 allocator().set_flags(allocator().flags() |
1251 cricket::PORTALLOCATOR_DISABLE_RELAY | 1265 cricket::PORTALLOCATOR_DISABLE_RELAY |
1252 cricket::PORTALLOCATOR_DISABLE_TCP | 1266 cricket::PORTALLOCATOR_DISABLE_TCP |
1253 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); 1267 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
1254 EXPECT_EQ(0U, allocator_->flags() & 1268 EXPECT_EQ(0U, allocator_->flags() &
1255 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); 1269 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION);
1256 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 1270 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
1257 EXPECT_EQ(0U, session_->flags() & 1271 EXPECT_EQ(0U, session_->flags() &
1258 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); 1272 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION);
1259 session_->StartGettingPorts(); 1273 session_->StartGettingPorts();
1260 EXPECT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout); 1274 EXPECT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout);
1261 EXPECT_EQ(0U, candidates_.size()); 1275 EXPECT_EQ(1U, candidates_.size());
1276 EXPECT_PRED5(CheckCandidate, candidates_[0],
1277 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp",
1278 kPrivateAddr);
1262 EXPECT_TRUE((session_->flags() & 1279 EXPECT_TRUE((session_->flags() &
1263 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) != 0); 1280 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) != 0);
1264 } 1281 }
1265 1282
1266 // This test verifies allocator can use IPv6 addresses along with IPv4. 1283 // This test verifies allocator can use IPv6 addresses along with IPv4.
1267 TEST_F(PortAllocatorTest, TestEnableIPv6Addresses) { 1284 TEST_F(PortAllocatorTest, TestEnableIPv6Addresses) {
1268 allocator().set_flags(allocator().flags() | 1285 allocator().set_flags(allocator().flags() |
1269 cricket::PORTALLOCATOR_DISABLE_RELAY | 1286 cricket::PORTALLOCATOR_DISABLE_RELAY |
1270 cricket::PORTALLOCATOR_ENABLE_IPV6 | 1287 cricket::PORTALLOCATOR_ENABLE_IPV6 |
1271 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); 1288 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 1343
1327 // After clearing getting ports, adding a new interface will start getting 1344 // After clearing getting ports, adding a new interface will start getting
1328 // ports again. 1345 // ports again.
1329 candidates_.clear(); 1346 candidates_.clear();
1330 ports_.clear(); 1347 ports_.clear();
1331 candidate_allocation_done_ = false; 1348 candidate_allocation_done_ = false;
1332 network_manager_.AddInterface(kClientAddr2); 1349 network_manager_.AddInterface(kClientAddr2);
1333 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); 1350 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000);
1334 EXPECT_EQ(2U, ports_.size()); 1351 EXPECT_EQ(2U, ports_.size());
1335 } 1352 }
OLDNEW
« no previous file with comments | « webrtc/p2p/client/basicportallocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698