| OLD | NEW |
| 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 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 #include <memory> | 12 #include <memory> |
| 13 | 13 |
| 14 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | 14 #include "webrtc/p2p/base/basicpacketsocketfactory.h" |
| 15 #include "webrtc/p2p/base/p2pconstants.h" | 15 #include "webrtc/p2p/base/p2pconstants.h" |
| 16 #include "webrtc/p2p/base/p2ptransportchannel.h" | 16 #include "webrtc/p2p/base/p2ptransportchannel.h" |
| 17 #include "webrtc/p2p/base/testrelayserver.h" | 17 #include "webrtc/p2p/base/testrelayserver.h" |
| 18 #include "webrtc/p2p/base/teststunserver.h" | 18 #include "webrtc/p2p/base/teststunserver.h" |
| 19 #include "webrtc/p2p/base/testturnserver.h" | 19 #include "webrtc/p2p/base/testturnserver.h" |
| 20 #include "webrtc/p2p/client/basicportallocator.h" | 20 #include "webrtc/p2p/client/basicportallocator.h" |
| 21 #include "webrtc/base/fakeclock.h" |
| 21 #include "webrtc/base/fakenetwork.h" | 22 #include "webrtc/base/fakenetwork.h" |
| 22 #include "webrtc/base/firewallsocketserver.h" | 23 #include "webrtc/base/firewallsocketserver.h" |
| 23 #include "webrtc/base/gunit.h" | 24 #include "webrtc/base/gunit.h" |
| 24 #include "webrtc/base/helpers.h" | 25 #include "webrtc/base/helpers.h" |
| 25 #include "webrtc/base/ipaddress.h" | 26 #include "webrtc/base/ipaddress.h" |
| 26 #include "webrtc/base/logging.h" | 27 #include "webrtc/base/logging.h" |
| 27 #include "webrtc/base/natserver.h" | 28 #include "webrtc/base/natserver.h" |
| 28 #include "webrtc/base/natsocketfactory.h" | 29 #include "webrtc/base/natsocketfactory.h" |
| 29 #include "webrtc/base/network.h" | 30 #include "webrtc/base/network.h" |
| 30 #include "webrtc/base/physicalsocketserver.h" | 31 #include "webrtc/base/physicalsocketserver.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 static const char kIceUfrag0[] = "UF00"; | 77 static const char kIceUfrag0[] = "UF00"; |
| 77 // Based on ICE_PWD_LENGTH | 78 // Based on ICE_PWD_LENGTH |
| 78 static const char kIcePwd0[] = "TESTICEPWD00000000000000"; | 79 static const char kIcePwd0[] = "TESTICEPWD00000000000000"; |
| 79 | 80 |
| 80 static const char kContentName[] = "test content"; | 81 static const char kContentName[] = "test content"; |
| 81 | 82 |
| 82 static const int kDefaultAllocationTimeout = 3000; | 83 static const int kDefaultAllocationTimeout = 3000; |
| 83 static const char kTurnUsername[] = "test"; | 84 static const char kTurnUsername[] = "test"; |
| 84 static const char kTurnPassword[] = "test"; | 85 static const char kTurnPassword[] = "test"; |
| 85 | 86 |
| 86 // STUN timeout (with all retries) is 9500ms. | |
| 87 // Add some margin of error for slow bots. | |
| 88 // TODO(deadbeef): Use simulated clock instead of just increasing timeouts to | |
| 89 // fix flaky tests. | |
| 90 static const int kStunTimeoutMs = 15000; | |
| 91 | |
| 92 namespace cricket { | 87 namespace cricket { |
| 93 | 88 |
| 94 // Helper for dumping candidates | 89 // Helper for dumping candidates |
| 95 std::ostream& operator<<(std::ostream& os, | 90 std::ostream& operator<<(std::ostream& os, |
| 96 const std::vector<Candidate>& candidates) { | 91 const std::vector<Candidate>& candidates) { |
| 97 os << '['; | 92 os << '['; |
| 98 bool first = true; | 93 bool first = true; |
| 99 for (const Candidate& c : candidates) { | 94 for (const Candidate& c : candidates) { |
| 100 if (!first) { | 95 if (!first) { |
| 101 os << ", "; | 96 os << ", "; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 network_manager_.set_default_local_addresses(kPrivateAddr.ipaddr(), | 376 network_manager_.set_default_local_addresses(kPrivateAddr.ipaddr(), |
| 382 rtc::IPAddress()); | 377 rtc::IPAddress()); |
| 383 if (!session_) { | 378 if (!session_) { |
| 384 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 379 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 385 } | 380 } |
| 386 session_->set_flags(session_->flags() | | 381 session_->set_flags(session_->flags() | |
| 387 PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION | | 382 PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION | |
| 388 PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 383 PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 389 allocator().set_allow_tcp_listen(false); | 384 allocator().set_allow_tcp_listen(false); |
| 390 session_->StartGettingPorts(); | 385 session_->StartGettingPorts(); |
| 391 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 386 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 387 kDefaultAllocationTimeout, fake_clock); |
| 392 | 388 |
| 393 uint32_t total_candidates = 0; | 389 uint32_t total_candidates = 0; |
| 394 if (!host_candidate_addr.IsNil()) { | 390 if (!host_candidate_addr.IsNil()) { |
| 395 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", | 391 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", |
| 396 rtc::SocketAddress(kPrivateAddr.ipaddr(), 0)); | 392 rtc::SocketAddress(kPrivateAddr.ipaddr(), 0)); |
| 397 ++total_candidates; | 393 ++total_candidates; |
| 398 } | 394 } |
| 399 if (!stun_candidate_addr.IsNil()) { | 395 if (!stun_candidate_addr.IsNil()) { |
| 400 rtc::SocketAddress related_address(host_candidate_addr, 0); | 396 rtc::SocketAddress related_address(host_candidate_addr, 0); |
| 401 if (host_candidate_addr.IsNil()) { | 397 if (host_candidate_addr.IsNil()) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 allocator_->SetConfiguration(allocator_->stun_servers(), | 517 allocator_->SetConfiguration(allocator_->stun_servers(), |
| 522 allocator_->turn_servers(), 0, true); | 518 allocator_->turn_servers(), 0, true); |
| 523 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); | 519 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); |
| 524 allocator_->set_step_delay(kMinimumStepDelay); | 520 allocator_->set_step_delay(kMinimumStepDelay); |
| 525 allocator_->set_flags(allocator().flags() | | 521 allocator_->set_flags(allocator().flags() | |
| 526 PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 522 PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 527 PORTALLOCATOR_DISABLE_TCP); | 523 PORTALLOCATOR_DISABLE_TCP); |
| 528 | 524 |
| 529 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 525 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 530 session_->StartGettingPorts(); | 526 session_->StartGettingPorts(); |
| 531 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 527 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 528 kDefaultAllocationTimeout, fake_clock); |
| 532 // Only 2 ports (one STUN and one TURN) are actually being used. | 529 // Only 2 ports (one STUN and one TURN) are actually being used. |
| 533 EXPECT_EQ(2U, session_->ReadyPorts().size()); | 530 EXPECT_EQ(2U, session_->ReadyPorts().size()); |
| 534 // We have verified that each port, when it is added to |ports_|, it is | 531 // We have verified that each port, when it is added to |ports_|, it is |
| 535 // found in |ready_ports|, and when it is pruned, it is not found in | 532 // found in |ready_ports|, and when it is pruned, it is not found in |
| 536 // |ready_ports|, so we only need to verify the content in one of them. | 533 // |ready_ports|, so we only need to verify the content in one of them. |
| 537 EXPECT_EQ(2U, ports_.size()); | 534 EXPECT_EQ(2U, ports_.size()); |
| 538 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr)); | 535 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr)); |
| 539 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kClientAddr)); | 536 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kClientAddr)); |
| 540 EXPECT_EQ(0, CountPorts(ports_, "relay", PROTO_TCP, kClientAddr)); | 537 EXPECT_EQ(0, CountPorts(ports_, "relay", PROTO_TCP, kClientAddr)); |
| 541 | 538 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 564 AddTurnServers(kTurnUdpIntIPv6Addr, rtc::SocketAddress()); | 561 AddTurnServers(kTurnUdpIntIPv6Addr, rtc::SocketAddress()); |
| 565 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); | 562 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |
| 566 | 563 |
| 567 allocator_->set_step_delay(kMinimumStepDelay); | 564 allocator_->set_step_delay(kMinimumStepDelay); |
| 568 allocator_->set_flags( | 565 allocator_->set_flags( |
| 569 allocator().flags() | PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 566 allocator().flags() | PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 570 PORTALLOCATOR_ENABLE_IPV6 | PORTALLOCATOR_DISABLE_TCP); | 567 PORTALLOCATOR_ENABLE_IPV6 | PORTALLOCATOR_DISABLE_TCP); |
| 571 | 568 |
| 572 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 569 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 573 session_->StartGettingPorts(); | 570 session_->StartGettingPorts(); |
| 574 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 571 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 572 kDefaultAllocationTimeout, fake_clock); |
| 575 // Three ports (one IPv4 STUN, one IPv6 STUN and one TURN) will be ready. | 573 // Three ports (one IPv4 STUN, one IPv6 STUN and one TURN) will be ready. |
| 576 EXPECT_EQ(3U, session_->ReadyPorts().size()); | 574 EXPECT_EQ(3U, session_->ReadyPorts().size()); |
| 577 EXPECT_EQ(3U, ports_.size()); | 575 EXPECT_EQ(3U, ports_.size()); |
| 578 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr)); | 576 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr)); |
| 579 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientIPv6Addr)); | 577 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientIPv6Addr)); |
| 580 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kClientIPv6Addr)); | 578 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kClientIPv6Addr)); |
| 581 EXPECT_EQ(0, CountPorts(ports_, "relay", PROTO_UDP, kClientAddr)); | 579 EXPECT_EQ(0, CountPorts(ports_, "relay", PROTO_UDP, kClientAddr)); |
| 582 | 580 |
| 583 // Now that we remove candidates when a TURN port is pruned, there will be | 581 // Now that we remove candidates when a TURN port is pruned, there will be |
| 584 // exactly 3 candidates in both |candidates_| and |ready_candidates|. | 582 // exactly 3 candidates in both |candidates_| and |ready_candidates|. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 606 // Have both UDP/TCP and IPv4/IPv6 TURN ports. | 604 // Have both UDP/TCP and IPv4/IPv6 TURN ports. |
| 607 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); | 605 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); |
| 608 AddTurnServers(kTurnUdpIntIPv6Addr, kTurnTcpIntIPv6Addr); | 606 AddTurnServers(kTurnUdpIntIPv6Addr, kTurnTcpIntIPv6Addr); |
| 609 | 607 |
| 610 allocator_->set_step_delay(kMinimumStepDelay); | 608 allocator_->set_step_delay(kMinimumStepDelay); |
| 611 allocator_->set_flags(allocator().flags() | | 609 allocator_->set_flags(allocator().flags() | |
| 612 PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 610 PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 613 PORTALLOCATOR_ENABLE_IPV6); | 611 PORTALLOCATOR_ENABLE_IPV6); |
| 614 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 612 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 615 session_->StartGettingPorts(); | 613 session_->StartGettingPorts(); |
| 616 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 614 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 615 kDefaultAllocationTimeout, fake_clock); |
| 617 // 10 ports (4 STUN and 1 TURN ports on each interface) will be ready to | 616 // 10 ports (4 STUN and 1 TURN ports on each interface) will be ready to |
| 618 // use. | 617 // use. |
| 619 EXPECT_EQ(10U, session_->ReadyPorts().size()); | 618 EXPECT_EQ(10U, session_->ReadyPorts().size()); |
| 620 EXPECT_EQ(10U, ports_.size()); | 619 EXPECT_EQ(10U, ports_.size()); |
| 621 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr)); | 620 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr)); |
| 622 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr2)); | 621 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientAddr2)); |
| 623 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientIPv6Addr)); | 622 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientIPv6Addr)); |
| 624 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientIPv6Addr2)); | 623 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_UDP, kClientIPv6Addr2)); |
| 625 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_TCP, kClientAddr)); | 624 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_TCP, kClientAddr)); |
| 626 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_TCP, kClientAddr2)); | 625 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_TCP, kClientAddr2)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 644 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", kClientAddr); | 643 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", kClientAddr); |
| 645 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", kClientAddr2); | 644 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", kClientAddr2); |
| 646 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", | 645 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", |
| 647 kClientIPv6Addr); | 646 kClientIPv6Addr); |
| 648 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", | 647 EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", |
| 649 kClientIPv6Addr2); | 648 kClientIPv6Addr2); |
| 650 EXPECT_PRED4(HasCandidate, ready_candidates, "relay", "udp", | 649 EXPECT_PRED4(HasCandidate, ready_candidates, "relay", "udp", |
| 651 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); | 650 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); |
| 652 } | 651 } |
| 653 | 652 |
| 653 rtc::ScopedFakeClock fake_clock; |
| 654 std::unique_ptr<rtc::PhysicalSocketServer> pss_; | 654 std::unique_ptr<rtc::PhysicalSocketServer> pss_; |
| 655 std::unique_ptr<rtc::VirtualSocketServer> vss_; | 655 std::unique_ptr<rtc::VirtualSocketServer> vss_; |
| 656 std::unique_ptr<rtc::FirewallSocketServer> fss_; | 656 std::unique_ptr<rtc::FirewallSocketServer> fss_; |
| 657 rtc::SocketServerScope ss_scope_; | 657 rtc::SocketServerScope ss_scope_; |
| 658 std::unique_ptr<rtc::NATServer> nat_server_; | 658 std::unique_ptr<rtc::NATServer> nat_server_; |
| 659 rtc::NATSocketFactory nat_factory_; | 659 rtc::NATSocketFactory nat_factory_; |
| 660 std::unique_ptr<rtc::BasicPacketSocketFactory> nat_socket_factory_; | 660 std::unique_ptr<rtc::BasicPacketSocketFactory> nat_socket_factory_; |
| 661 std::unique_ptr<TestStunServer> stun_server_; | 661 std::unique_ptr<TestStunServer> stun_server_; |
| 662 TestRelayServer relay_server_; | 662 TestRelayServer relay_server_; |
| 663 TestTurnServer turn_server_; | 663 TestTurnServer turn_server_; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 AddInterface(SocketAddress(IPAddress(0x12345602U), 0), "test_cell0", | 695 AddInterface(SocketAddress(IPAddress(0x12345602U), 0), "test_cell0", |
| 696 rtc::ADAPTER_TYPE_CELLULAR); | 696 rtc::ADAPTER_TYPE_CELLULAR); |
| 697 AddInterface(SocketAddress(IPAddress(0x12345603U), 0), "test_vpn0", | 697 AddInterface(SocketAddress(IPAddress(0x12345603U), 0), "test_vpn0", |
| 698 rtc::ADAPTER_TYPE_VPN); | 698 rtc::ADAPTER_TYPE_VPN); |
| 699 AddInterface(SocketAddress(IPAddress(0x12345604U), 0), "test_lo", | 699 AddInterface(SocketAddress(IPAddress(0x12345604U), 0), "test_lo", |
| 700 rtc::ADAPTER_TYPE_LOOPBACK); | 700 rtc::ADAPTER_TYPE_LOOPBACK); |
| 701 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 701 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 702 session_->set_flags(PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | | 702 session_->set_flags(PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | |
| 703 PORTALLOCATOR_DISABLE_TCP); | 703 PORTALLOCATOR_DISABLE_TCP); |
| 704 session_->StartGettingPorts(); | 704 session_->StartGettingPorts(); |
| 705 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 705 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 706 kDefaultAllocationTimeout, fake_clock); |
| 706 EXPECT_EQ(4U, candidates_.size()); | 707 EXPECT_EQ(4U, candidates_.size()); |
| 707 for (Candidate candidate : candidates_) { | 708 for (Candidate candidate : candidates_) { |
| 708 EXPECT_LT(candidate.address().ip(), 0x12345604U); | 709 EXPECT_LT(candidate.address().ip(), 0x12345604U); |
| 709 } | 710 } |
| 710 } | 711 } |
| 711 | 712 |
| 712 TEST_F(BasicPortAllocatorTest, TestIgnoreNetworksAccordingToIgnoreMask) { | 713 TEST_F(BasicPortAllocatorTest, TestIgnoreNetworksAccordingToIgnoreMask) { |
| 713 AddInterface(SocketAddress(IPAddress(0x12345600U), 0), "test_eth0", | 714 AddInterface(SocketAddress(IPAddress(0x12345600U), 0), "test_eth0", |
| 714 rtc::ADAPTER_TYPE_ETHERNET); | 715 rtc::ADAPTER_TYPE_ETHERNET); |
| 715 AddInterface(SocketAddress(IPAddress(0x12345601U), 0), "test_wlan0", | 716 AddInterface(SocketAddress(IPAddress(0x12345601U), 0), "test_wlan0", |
| 716 rtc::ADAPTER_TYPE_WIFI); | 717 rtc::ADAPTER_TYPE_WIFI); |
| 717 AddInterface(SocketAddress(IPAddress(0x12345602U), 0), "test_cell0", | 718 AddInterface(SocketAddress(IPAddress(0x12345602U), 0), "test_cell0", |
| 718 rtc::ADAPTER_TYPE_CELLULAR); | 719 rtc::ADAPTER_TYPE_CELLULAR); |
| 719 allocator_->SetNetworkIgnoreMask(rtc::ADAPTER_TYPE_ETHERNET | | 720 allocator_->SetNetworkIgnoreMask(rtc::ADAPTER_TYPE_ETHERNET | |
| 720 rtc::ADAPTER_TYPE_LOOPBACK | | 721 rtc::ADAPTER_TYPE_LOOPBACK | |
| 721 rtc::ADAPTER_TYPE_WIFI); | 722 rtc::ADAPTER_TYPE_WIFI); |
| 722 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 723 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 723 session_->set_flags(PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | | 724 session_->set_flags(PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | |
| 724 PORTALLOCATOR_DISABLE_TCP); | 725 PORTALLOCATOR_DISABLE_TCP); |
| 725 session_->StartGettingPorts(); | 726 session_->StartGettingPorts(); |
| 726 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 727 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 728 kDefaultAllocationTimeout, fake_clock); |
| 727 EXPECT_EQ(1U, candidates_.size()); | 729 EXPECT_EQ(1U, candidates_.size()); |
| 728 EXPECT_EQ(0x12345602U, candidates_[0].address().ip()); | 730 EXPECT_EQ(0x12345602U, candidates_[0].address().ip()); |
| 729 } | 731 } |
| 730 | 732 |
| 731 // Test that high cost networks are filtered if the flag | 733 // Test that high cost networks are filtered if the flag |
| 732 // PORTALLOCATOR_DISABLE_COSTLY_NETWORKS is set. | 734 // PORTALLOCATOR_DISABLE_COSTLY_NETWORKS is set. |
| 733 TEST_F(BasicPortAllocatorTest, TestGatherLowCostNetworkOnly) { | 735 TEST_F(BasicPortAllocatorTest, TestGatherLowCostNetworkOnly) { |
| 734 SocketAddress addr_wifi(IPAddress(0x12345600U), 0); | 736 SocketAddress addr_wifi(IPAddress(0x12345600U), 0); |
| 735 SocketAddress addr_cellular(IPAddress(0x12345601U), 0); | 737 SocketAddress addr_cellular(IPAddress(0x12345601U), 0); |
| 736 SocketAddress addr_unknown1(IPAddress(0x12345602U), 0); | 738 SocketAddress addr_unknown1(IPAddress(0x12345602U), 0); |
| 737 SocketAddress addr_unknown2(IPAddress(0x12345603U), 0); | 739 SocketAddress addr_unknown2(IPAddress(0x12345603U), 0); |
| 738 // If both Wi-Fi and cellular interfaces are present, only gather on the Wi-Fi | 740 // If both Wi-Fi and cellular interfaces are present, only gather on the Wi-Fi |
| 739 // interface. | 741 // interface. |
| 740 AddInterface(addr_wifi, "test_wlan0", rtc::ADAPTER_TYPE_WIFI); | 742 AddInterface(addr_wifi, "test_wlan0", rtc::ADAPTER_TYPE_WIFI); |
| 741 AddInterface(addr_cellular, "test_cell0", rtc::ADAPTER_TYPE_CELLULAR); | 743 AddInterface(addr_cellular, "test_cell0", rtc::ADAPTER_TYPE_CELLULAR); |
| 742 allocator().set_flags(cricket::PORTALLOCATOR_DISABLE_STUN | | 744 allocator().set_flags(cricket::PORTALLOCATOR_DISABLE_STUN | |
| 743 cricket::PORTALLOCATOR_DISABLE_RELAY | | 745 cricket::PORTALLOCATOR_DISABLE_RELAY | |
| 744 cricket::PORTALLOCATOR_DISABLE_TCP | | 746 cricket::PORTALLOCATOR_DISABLE_TCP | |
| 745 cricket::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); | 747 cricket::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); |
| 746 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 748 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 747 session_->StartGettingPorts(); | 749 session_->StartGettingPorts(); |
| 748 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 750 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 751 kDefaultAllocationTimeout, fake_clock); |
| 749 EXPECT_EQ(1U, candidates_.size()); | 752 EXPECT_EQ(1U, candidates_.size()); |
| 750 EXPECT_TRUE(addr_wifi.EqualIPs(candidates_[0].address())); | 753 EXPECT_TRUE(addr_wifi.EqualIPs(candidates_[0].address())); |
| 751 | 754 |
| 752 // If both cellular and unknown interfaces are present, only gather on the | 755 // If both cellular and unknown interfaces are present, only gather on the |
| 753 // unknown interfaces. | 756 // unknown interfaces. |
| 754 candidates_.clear(); | 757 candidates_.clear(); |
| 755 candidate_allocation_done_ = false; | 758 candidate_allocation_done_ = false; |
| 756 RemoveInterface(addr_wifi); | 759 RemoveInterface(addr_wifi); |
| 757 AddInterface(addr_unknown1, "test_unknown0", rtc::ADAPTER_TYPE_UNKNOWN); | 760 AddInterface(addr_unknown1, "test_unknown0", rtc::ADAPTER_TYPE_UNKNOWN); |
| 758 AddInterface(addr_unknown2, "test_unknown1", rtc::ADAPTER_TYPE_UNKNOWN); | 761 AddInterface(addr_unknown2, "test_unknown1", rtc::ADAPTER_TYPE_UNKNOWN); |
| 759 session_->StartGettingPorts(); | 762 session_->StartGettingPorts(); |
| 760 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 763 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 764 kDefaultAllocationTimeout, fake_clock); |
| 761 EXPECT_EQ(2U, candidates_.size()); | 765 EXPECT_EQ(2U, candidates_.size()); |
| 762 EXPECT_TRUE((addr_unknown1.EqualIPs(candidates_[0].address()) && | 766 EXPECT_TRUE((addr_unknown1.EqualIPs(candidates_[0].address()) && |
| 763 addr_unknown2.EqualIPs(candidates_[1].address())) || | 767 addr_unknown2.EqualIPs(candidates_[1].address())) || |
| 764 (addr_unknown1.EqualIPs(candidates_[1].address()) && | 768 (addr_unknown1.EqualIPs(candidates_[1].address()) && |
| 765 addr_unknown2.EqualIPs(candidates_[0].address()))); | 769 addr_unknown2.EqualIPs(candidates_[0].address()))); |
| 766 | 770 |
| 767 // If Wi-Fi, cellular, unknown interfaces are all present, only gather on the | 771 // If Wi-Fi, cellular, unknown interfaces are all present, only gather on the |
| 768 // Wi-Fi interface. | 772 // Wi-Fi interface. |
| 769 candidates_.clear(); | 773 candidates_.clear(); |
| 770 candidate_allocation_done_ = false; | 774 candidate_allocation_done_ = false; |
| 771 AddInterface(addr_wifi, "test_wlan0", rtc::ADAPTER_TYPE_WIFI); | 775 AddInterface(addr_wifi, "test_wlan0", rtc::ADAPTER_TYPE_WIFI); |
| 772 session_->StartGettingPorts(); | 776 session_->StartGettingPorts(); |
| 773 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 777 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 778 kDefaultAllocationTimeout, fake_clock); |
| 774 EXPECT_EQ(1U, candidates_.size()); | 779 EXPECT_EQ(1U, candidates_.size()); |
| 775 EXPECT_TRUE(addr_wifi.EqualIPs(candidates_[0].address())); | 780 EXPECT_TRUE(addr_wifi.EqualIPs(candidates_[0].address())); |
| 776 } | 781 } |
| 777 | 782 |
| 778 // Test that we could use loopback interface as host candidate. | 783 // Test that we could use loopback interface as host candidate. |
| 779 TEST_F(BasicPortAllocatorTest, TestLoopbackNetworkInterface) { | 784 TEST_F(BasicPortAllocatorTest, TestLoopbackNetworkInterface) { |
| 780 AddInterface(kLoopbackAddr, "test_loopback", rtc::ADAPTER_TYPE_LOOPBACK); | 785 AddInterface(kLoopbackAddr, "test_loopback", rtc::ADAPTER_TYPE_LOOPBACK); |
| 781 allocator_->SetNetworkIgnoreMask(0); | 786 allocator_->SetNetworkIgnoreMask(0); |
| 782 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 787 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 783 session_->set_flags(PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | | 788 session_->set_flags(PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | |
| 784 PORTALLOCATOR_DISABLE_TCP); | 789 PORTALLOCATOR_DISABLE_TCP); |
| 785 session_->StartGettingPorts(); | 790 session_->StartGettingPorts(); |
| 786 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 791 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 792 kDefaultAllocationTimeout, fake_clock); |
| 787 EXPECT_EQ(1U, candidates_.size()); | 793 EXPECT_EQ(1U, candidates_.size()); |
| 788 } | 794 } |
| 789 | 795 |
| 790 // Tests that we can get all the desired addresses successfully. | 796 // Tests that we can get all the desired addresses successfully. |
| 791 TEST_F(BasicPortAllocatorTest, TestGetAllPortsWithMinimumStepDelay) { | 797 TEST_F(BasicPortAllocatorTest, TestGetAllPortsWithMinimumStepDelay) { |
| 792 AddInterface(kClientAddr); | 798 AddInterface(kClientAddr); |
| 793 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 799 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 794 session_->StartGettingPorts(); | 800 session_->StartGettingPorts(); |
| 795 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); | 801 ASSERT_EQ_SIMULATED_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout, |
| 802 fake_clock); |
| 796 EXPECT_EQ(4U, ports_.size()); | 803 EXPECT_EQ(4U, ports_.size()); |
| 797 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); | 804 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 798 EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", kClientAddr); | 805 EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", kClientAddr); |
| 799 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); | 806 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); |
| 800 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); | 807 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); |
| 801 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); | 808 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); |
| 802 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); | 809 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 803 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", | 810 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", |
| 804 kRelaySslTcpIntAddr); | 811 kRelaySslTcpIntAddr); |
| 805 EXPECT_TRUE(candidate_allocation_done_); | 812 EXPECT_TRUE(candidate_allocation_done_); |
| 806 } | 813 } |
| 807 | 814 |
| 808 // Test that when the same network interface is brought down and up, the | 815 // Test that when the same network interface is brought down and up, the |
| 809 // port allocator session will restart a new allocation sequence if | 816 // port allocator session will restart a new allocation sequence if |
| 810 // it is not stopped. | 817 // it is not stopped. |
| 811 TEST_F(BasicPortAllocatorTest, TestSameNetworkDownAndUpWhenSessionNotStopped) { | 818 TEST_F(BasicPortAllocatorTest, TestSameNetworkDownAndUpWhenSessionNotStopped) { |
| 812 std::string if_name("test_net0"); | 819 std::string if_name("test_net0"); |
| 813 AddInterface(kClientAddr, if_name); | 820 AddInterface(kClientAddr, if_name); |
| 814 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 821 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 815 session_->StartGettingPorts(); | 822 session_->StartGettingPorts(); |
| 816 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); | 823 ASSERT_EQ_SIMULATED_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout, |
| 824 fake_clock); |
| 817 EXPECT_EQ(4U, ports_.size()); | 825 EXPECT_EQ(4U, ports_.size()); |
| 818 EXPECT_TRUE(candidate_allocation_done_); | 826 EXPECT_TRUE(candidate_allocation_done_); |
| 819 candidate_allocation_done_ = false; | 827 candidate_allocation_done_ = false; |
| 820 candidates_.clear(); | 828 candidates_.clear(); |
| 821 ports_.clear(); | 829 ports_.clear(); |
| 822 | 830 |
| 823 RemoveInterface(kClientAddr); | 831 RemoveInterface(kClientAddr); |
| 824 ASSERT_EQ_WAIT(0U, candidates_.size(), kDefaultAllocationTimeout); | 832 ASSERT_EQ_SIMULATED_WAIT(0U, candidates_.size(), kDefaultAllocationTimeout, |
| 833 fake_clock); |
| 825 EXPECT_EQ(0U, ports_.size()); | 834 EXPECT_EQ(0U, ports_.size()); |
| 826 EXPECT_FALSE(candidate_allocation_done_); | 835 EXPECT_FALSE(candidate_allocation_done_); |
| 827 | 836 |
| 828 // When the same interfaces are added again, new candidates/ports should be | 837 // When the same interfaces are added again, new candidates/ports should be |
| 829 // generated. | 838 // generated. |
| 830 AddInterface(kClientAddr, if_name); | 839 AddInterface(kClientAddr, if_name); |
| 831 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); | 840 ASSERT_EQ_SIMULATED_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout, |
| 841 fake_clock); |
| 832 EXPECT_EQ(4U, ports_.size()); | 842 EXPECT_EQ(4U, ports_.size()); |
| 833 EXPECT_TRUE(candidate_allocation_done_); | 843 EXPECT_TRUE(candidate_allocation_done_); |
| 834 } | 844 } |
| 835 | 845 |
| 836 // Test that when the same network interface is brought down and up, the | 846 // Test that when the same network interface is brought down and up, the |
| 837 // port allocator session will not restart a new allocation sequence if | 847 // port allocator session will not restart a new allocation sequence if |
| 838 // it is stopped. | 848 // it is stopped. |
| 839 TEST_F(BasicPortAllocatorTest, TestSameNetworkDownAndUpWhenSessionStopped) { | 849 TEST_F(BasicPortAllocatorTest, TestSameNetworkDownAndUpWhenSessionStopped) { |
| 840 std::string if_name("test_net0"); | 850 std::string if_name("test_net0"); |
| 841 AddInterface(kClientAddr, if_name); | 851 AddInterface(kClientAddr, if_name); |
| 842 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 852 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 843 session_->StartGettingPorts(); | 853 session_->StartGettingPorts(); |
| 844 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); | 854 ASSERT_EQ_SIMULATED_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout, |
| 855 fake_clock); |
| 845 EXPECT_EQ(4U, ports_.size()); | 856 EXPECT_EQ(4U, ports_.size()); |
| 846 EXPECT_TRUE(candidate_allocation_done_); | 857 EXPECT_TRUE(candidate_allocation_done_); |
| 847 session_->StopGettingPorts(); | 858 session_->StopGettingPorts(); |
| 848 candidates_.clear(); | 859 candidates_.clear(); |
| 849 ports_.clear(); | 860 ports_.clear(); |
| 850 | 861 |
| 851 RemoveInterface(kClientAddr); | 862 RemoveInterface(kClientAddr); |
| 852 ASSERT_EQ_WAIT(0U, candidates_.size(), kDefaultAllocationTimeout); | 863 ASSERT_EQ_SIMULATED_WAIT(0U, candidates_.size(), kDefaultAllocationTimeout, |
| 864 fake_clock); |
| 853 EXPECT_EQ(0U, ports_.size()); | 865 EXPECT_EQ(0U, ports_.size()); |
| 854 | 866 |
| 855 // When the same interfaces are added again, new candidates/ports should not | 867 // When the same interfaces are added again, new candidates/ports should not |
| 856 // be generated because the session has stopped. | 868 // be generated because the session has stopped. |
| 857 AddInterface(kClientAddr, if_name); | 869 AddInterface(kClientAddr, if_name); |
| 858 ASSERT_EQ_WAIT(0U, candidates_.size(), kDefaultAllocationTimeout); | 870 ASSERT_EQ_SIMULATED_WAIT(0U, candidates_.size(), kDefaultAllocationTimeout, |
| 871 fake_clock); |
| 859 EXPECT_EQ(0U, ports_.size()); | 872 EXPECT_EQ(0U, ports_.size()); |
| 860 EXPECT_TRUE(candidate_allocation_done_); | 873 EXPECT_TRUE(candidate_allocation_done_); |
| 861 } | 874 } |
| 862 | 875 |
| 863 // Verify candidates with default step delay of 1sec. | 876 // Verify candidates with default step delay of 1sec. |
| 864 TEST_F(BasicPortAllocatorTest, TestGetAllPortsWithOneSecondStepDelay) { | 877 TEST_F(BasicPortAllocatorTest, TestGetAllPortsWithOneSecondStepDelay) { |
| 865 AddInterface(kClientAddr); | 878 AddInterface(kClientAddr); |
| 866 allocator_->set_step_delay(kDefaultStepDelay); | 879 allocator_->set_step_delay(kDefaultStepDelay); |
| 867 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 880 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 868 session_->StartGettingPorts(); | 881 session_->StartGettingPorts(); |
| 869 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); | 882 ASSERT_EQ_SIMULATED_WAIT(2U, candidates_.size(), 1000, fake_clock); |
| 870 EXPECT_EQ(2U, ports_.size()); | 883 EXPECT_EQ(2U, ports_.size()); |
| 871 ASSERT_EQ_WAIT(4U, candidates_.size(), 2000); | 884 ASSERT_EQ_SIMULATED_WAIT(4U, candidates_.size(), 2000, fake_clock); |
| 872 EXPECT_EQ(3U, ports_.size()); | 885 EXPECT_EQ(3U, ports_.size()); |
| 873 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); | 886 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); |
| 874 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); | 887 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); |
| 875 ASSERT_EQ_WAIT(6U, candidates_.size(), 1500); | 888 ASSERT_EQ_SIMULATED_WAIT(6U, candidates_.size(), 1500, fake_clock); |
| 876 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); | 889 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); |
| 877 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); | 890 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 878 EXPECT_EQ(4U, ports_.size()); | 891 EXPECT_EQ(4U, ports_.size()); |
| 879 ASSERT_EQ_WAIT(7U, candidates_.size(), 2000); | 892 ASSERT_EQ_SIMULATED_WAIT(7U, candidates_.size(), 2000, fake_clock); |
| 880 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", | 893 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", |
| 881 kRelaySslTcpIntAddr); | 894 kRelaySslTcpIntAddr); |
| 882 EXPECT_EQ(4U, ports_.size()); | 895 EXPECT_EQ(4U, ports_.size()); |
| 883 EXPECT_TRUE(candidate_allocation_done_); | 896 EXPECT_TRUE(candidate_allocation_done_); |
| 884 // If we Stop gathering now, we shouldn't get a second "done" callback. | 897 // If we Stop gathering now, we shouldn't get a second "done" callback. |
| 885 session_->StopGettingPorts(); | 898 session_->StopGettingPorts(); |
| 886 } | 899 } |
| 887 | 900 |
| 888 TEST_F(BasicPortAllocatorTest, TestSetupVideoRtpPortsWithNormalSendBuffers) { | 901 TEST_F(BasicPortAllocatorTest, TestSetupVideoRtpPortsWithNormalSendBuffers) { |
| 889 AddInterface(kClientAddr); | 902 AddInterface(kClientAddr); |
| 890 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP, CN_VIDEO)); | 903 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP, CN_VIDEO)); |
| 891 session_->StartGettingPorts(); | 904 session_->StartGettingPorts(); |
| 892 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); | 905 ASSERT_EQ_SIMULATED_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout, |
| 906 fake_clock); |
| 893 EXPECT_TRUE(candidate_allocation_done_); | 907 EXPECT_TRUE(candidate_allocation_done_); |
| 894 // If we Stop gathering now, we shouldn't get a second "done" callback. | 908 // If we Stop gathering now, we shouldn't get a second "done" callback. |
| 895 session_->StopGettingPorts(); | 909 session_->StopGettingPorts(); |
| 896 | 910 |
| 897 // All ports should have unset send-buffer sizes. | 911 // All ports should have unset send-buffer sizes. |
| 898 CheckSendBufferSizesOfAllPorts(-1); | 912 CheckSendBufferSizesOfAllPorts(-1); |
| 899 } | 913 } |
| 900 | 914 |
| 901 // Tests that we can get callback after StopGetAllPorts. | 915 // Tests that we can get callback after StopGetAllPorts. |
| 902 TEST_F(BasicPortAllocatorTest, TestStopGetAllPorts) { | 916 TEST_F(BasicPortAllocatorTest, TestStopGetAllPorts) { |
| 903 AddInterface(kClientAddr); | 917 AddInterface(kClientAddr); |
| 904 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 918 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 905 session_->StartGettingPorts(); | 919 session_->StartGettingPorts(); |
| 906 ASSERT_EQ_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout); | 920 ASSERT_EQ_SIMULATED_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout, |
| 921 fake_clock); |
| 907 EXPECT_EQ(2U, ports_.size()); | 922 EXPECT_EQ(2U, ports_.size()); |
| 908 session_->StopGettingPorts(); | 923 session_->StopGettingPorts(); |
| 909 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 924 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 925 kDefaultAllocationTimeout, fake_clock); |
| 910 } | 926 } |
| 911 | 927 |
| 912 // Test that we restrict client ports appropriately when a port range is set. | 928 // Test that we restrict client ports appropriately when a port range is set. |
| 913 // We check the candidates for udp/stun/tcp ports, and the from address | 929 // We check the candidates for udp/stun/tcp ports, and the from address |
| 914 // for relay ports. | 930 // for relay ports. |
| 915 TEST_F(BasicPortAllocatorTest, TestGetAllPortsPortRange) { | 931 TEST_F(BasicPortAllocatorTest, TestGetAllPortsPortRange) { |
| 916 AddInterface(kClientAddr); | 932 AddInterface(kClientAddr); |
| 917 // Check that an invalid port range fails. | 933 // Check that an invalid port range fails. |
| 918 EXPECT_FALSE(SetPortRange(kMaxPort, kMinPort)); | 934 EXPECT_FALSE(SetPortRange(kMaxPort, kMinPort)); |
| 919 // Check that a null port range succeeds. | 935 // Check that a null port range succeeds. |
| 920 EXPECT_TRUE(SetPortRange(0, 0)); | 936 EXPECT_TRUE(SetPortRange(0, 0)); |
| 921 // Check that a valid port range succeeds. | 937 // Check that a valid port range succeeds. |
| 922 EXPECT_TRUE(SetPortRange(kMinPort, kMaxPort)); | 938 EXPECT_TRUE(SetPortRange(kMinPort, kMaxPort)); |
| 923 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 939 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 924 session_->StartGettingPorts(); | 940 session_->StartGettingPorts(); |
| 925 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); | 941 ASSERT_EQ_SIMULATED_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout, |
| 942 fake_clock); |
| 926 EXPECT_EQ(4U, ports_.size()); | 943 EXPECT_EQ(4U, ports_.size()); |
| 927 | 944 |
| 928 int num_nonrelay_candidates = 0; | 945 int num_nonrelay_candidates = 0; |
| 929 for (const Candidate& candidate : candidates_) { | 946 for (const Candidate& candidate : candidates_) { |
| 930 // Check the port number for the UDP/STUN/TCP port objects. | 947 // Check the port number for the UDP/STUN/TCP port objects. |
| 931 if (candidate.type() != RELAY_PORT_TYPE) { | 948 if (candidate.type() != RELAY_PORT_TYPE) { |
| 932 EXPECT_PRED3(CheckPort, candidate.address(), kMinPort, kMaxPort); | 949 EXPECT_PRED3(CheckPort, candidate.address(), kMinPort, kMaxPort); |
| 933 ++num_nonrelay_candidates; | 950 ++num_nonrelay_candidates; |
| 934 } | 951 } |
| 935 } | 952 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 948 ResetWithStunServerAndNat(kStunAddr); | 965 ResetWithStunServerAndNat(kStunAddr); |
| 949 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); | 966 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); |
| 950 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); | 967 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); |
| 951 AddTurnServers(kTurnUdpIntIPv6Addr, kTurnTcpIntIPv6Addr); | 968 AddTurnServers(kTurnUdpIntIPv6Addr, kTurnTcpIntIPv6Addr); |
| 952 // Disable IPv6, because our test infrastructure doesn't support having IPv4 | 969 // Disable IPv6, because our test infrastructure doesn't support having IPv4 |
| 953 // behind a NAT but IPv6 not, or having an IPv6 NAT. | 970 // behind a NAT but IPv6 not, or having an IPv6 NAT. |
| 954 // TODO(deadbeef): Fix this. | 971 // TODO(deadbeef): Fix this. |
| 955 network_manager_.set_ipv6_enabled(false); | 972 network_manager_.set_ipv6_enabled(false); |
| 956 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 973 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 957 session_->StartGettingPorts(); | 974 session_->StartGettingPorts(); |
| 958 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 975 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 976 kDefaultAllocationTimeout, fake_clock); |
| 959 EXPECT_EQ(4U, ports_.size()); | 977 EXPECT_EQ(4U, ports_.size()); |
| 960 EXPECT_EQ(1, CountPorts(ports_, "stun", PROTO_UDP, kAnyAddr)); | 978 EXPECT_EQ(1, CountPorts(ports_, "stun", PROTO_UDP, kAnyAddr)); |
| 961 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_TCP, kAnyAddr)); | 979 EXPECT_EQ(1, CountPorts(ports_, "local", PROTO_TCP, kAnyAddr)); |
| 962 // Two TURN ports, using UDP/TCP for the first hop to the TURN server. | 980 // Two TURN ports, using UDP/TCP for the first hop to the TURN server. |
| 963 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kAnyAddr)); | 981 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_UDP, kAnyAddr)); |
| 964 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_TCP, kAnyAddr)); | 982 EXPECT_EQ(1, CountPorts(ports_, "relay", PROTO_TCP, kAnyAddr)); |
| 965 // The "any" address port should be in the signaled ready ports, but the host | 983 // The "any" address port should be in the signaled ready ports, but the host |
| 966 // candidate for it is useless and shouldn't be signaled. So we only have | 984 // candidate for it is useless and shouldn't be signaled. So we only have |
| 967 // STUN/TURN candidates. | 985 // STUN/TURN candidates. |
| 968 EXPECT_EQ(3U, candidates_.size()); | 986 EXPECT_EQ(3U, candidates_.size()); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); | 1103 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); |
| 1086 AddInterface(kClientAddr); | 1104 AddInterface(kClientAddr); |
| 1087 ResetWithStunServerAndNat(kStunAddr); | 1105 ResetWithStunServerAndNat(kStunAddr); |
| 1088 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); | 1106 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); |
| 1089 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1107 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1090 session_->set_flags(PORTALLOCATOR_DISABLE_UDP_RELAY | | 1108 session_->set_flags(PORTALLOCATOR_DISABLE_UDP_RELAY | |
| 1091 PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_STUN | | 1109 PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_STUN | |
| 1092 PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1110 PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1093 | 1111 |
| 1094 session_->StartGettingPorts(); | 1112 session_->StartGettingPorts(); |
| 1095 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1113 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1114 kDefaultAllocationTimeout, fake_clock); |
| 1096 | 1115 |
| 1097 // Expect to see 2 ports and 2 candidates - TURN/TCP and TCP ports, TCP and | 1116 // Expect to see 2 ports and 2 candidates - TURN/TCP and TCP ports, TCP and |
| 1098 // TURN/TCP candidates. | 1117 // TURN/TCP candidates. |
| 1099 EXPECT_EQ(2U, ports_.size()); | 1118 EXPECT_EQ(2U, ports_.size()); |
| 1100 EXPECT_EQ(2U, candidates_.size()); | 1119 EXPECT_EQ(2U, candidates_.size()); |
| 1101 Candidate turn_candidate; | 1120 Candidate turn_candidate; |
| 1102 EXPECT_PRED5(FindCandidate, candidates_, "relay", "udp", kTurnUdpExtAddr, | 1121 EXPECT_PRED5(FindCandidate, candidates_, "relay", "udp", kTurnUdpExtAddr, |
| 1103 &turn_candidate); | 1122 &turn_candidate); |
| 1104 // The TURN candidate should use TCP to contact the TURN server. | 1123 // The TURN candidate should use TCP to contact the TURN server. |
| 1105 EXPECT_EQ(TCP_PROTOCOL_NAME, turn_candidate.relay_protocol()); | 1124 EXPECT_EQ(TCP_PROTOCOL_NAME, turn_candidate.relay_protocol()); |
| 1106 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); | 1125 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 1107 } | 1126 } |
| 1108 | 1127 |
| 1109 // Disable for asan, see | 1128 // Disable for asan, see |
| 1110 // https://code.google.com/p/webrtc/issues/detail?id=4743 for details. | 1129 // https://code.google.com/p/webrtc/issues/detail?id=4743 for details. |
| 1111 #if !defined(ADDRESS_SANITIZER) | 1130 #if !defined(ADDRESS_SANITIZER) |
| 1112 | 1131 |
| 1113 // Test that we can get OnCandidatesAllocationDone callback when all the ports | 1132 // Test that we can get OnCandidatesAllocationDone callback when all the ports |
| 1114 // are disabled. | 1133 // are disabled. |
| 1115 TEST_F(BasicPortAllocatorTest, TestDisableAllPorts) { | 1134 TEST_F(BasicPortAllocatorTest, TestDisableAllPorts) { |
| 1116 AddInterface(kClientAddr); | 1135 AddInterface(kClientAddr); |
| 1117 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1136 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1118 session_->set_flags(PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_STUN | | 1137 session_->set_flags(PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_STUN | |
| 1119 PORTALLOCATOR_DISABLE_RELAY | PORTALLOCATOR_DISABLE_TCP); | 1138 PORTALLOCATOR_DISABLE_RELAY | PORTALLOCATOR_DISABLE_TCP); |
| 1120 session_->StartGettingPorts(); | 1139 session_->StartGettingPorts(); |
| 1121 rtc::Thread::Current()->ProcessMessages(100); | 1140 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, 1000, fake_clock); |
| 1122 EXPECT_EQ(0U, candidates_.size()); | 1141 EXPECT_EQ(0U, candidates_.size()); |
| 1123 EXPECT_TRUE(candidate_allocation_done_); | |
| 1124 } | 1142 } |
| 1125 | 1143 |
| 1126 // Test that we don't crash or malfunction if we can't create UDP sockets. | 1144 // Test that we don't crash or malfunction if we can't create UDP sockets. |
| 1127 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpSockets) { | 1145 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpSockets) { |
| 1128 AddInterface(kClientAddr); | 1146 AddInterface(kClientAddr); |
| 1129 fss_->set_udp_sockets_enabled(false); | 1147 fss_->set_udp_sockets_enabled(false); |
| 1130 EXPECT_TRUE(CreateSession(1)); | 1148 EXPECT_TRUE(CreateSession(1)); |
| 1131 session_->StartGettingPorts(); | 1149 session_->StartGettingPorts(); |
| 1132 ASSERT_EQ_WAIT(5U, candidates_.size(), kDefaultAllocationTimeout); | 1150 ASSERT_EQ_SIMULATED_WAIT(5U, candidates_.size(), kDefaultAllocationTimeout, |
| 1151 fake_clock); |
| 1133 EXPECT_EQ(2U, ports_.size()); | 1152 EXPECT_EQ(2U, ports_.size()); |
| 1134 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); | 1153 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); |
| 1135 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); | 1154 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); |
| 1136 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); | 1155 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); |
| 1137 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); | 1156 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 1138 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", | 1157 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", |
| 1139 kRelaySslTcpIntAddr); | 1158 kRelaySslTcpIntAddr); |
| 1140 EXPECT_TRUE(candidate_allocation_done_); | 1159 EXPECT_TRUE(candidate_allocation_done_); |
| 1141 } | 1160 } |
| 1142 | 1161 |
| 1143 #endif // if !defined(ADDRESS_SANITIZER) | 1162 #endif // if !defined(ADDRESS_SANITIZER) |
| 1144 | 1163 |
| 1145 // Test that we don't crash or malfunction if we can't create UDP sockets or | 1164 // Test that we don't crash or malfunction if we can't create UDP sockets or |
| 1146 // listen on TCP sockets. We still give out a local TCP address, since | 1165 // listen on TCP sockets. We still give out a local TCP address, since |
| 1147 // apparently this is needed for the remote side to accept our connection. | 1166 // apparently this is needed for the remote side to accept our connection. |
| 1148 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpSocketsNoTcpListen) { | 1167 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpSocketsNoTcpListen) { |
| 1149 AddInterface(kClientAddr); | 1168 AddInterface(kClientAddr); |
| 1150 fss_->set_udp_sockets_enabled(false); | 1169 fss_->set_udp_sockets_enabled(false); |
| 1151 fss_->set_tcp_listen_enabled(false); | 1170 fss_->set_tcp_listen_enabled(false); |
| 1152 EXPECT_TRUE(CreateSession(1)); | 1171 EXPECT_TRUE(CreateSession(1)); |
| 1153 session_->StartGettingPorts(); | 1172 session_->StartGettingPorts(); |
| 1154 ASSERT_EQ_WAIT(5U, candidates_.size(), kDefaultAllocationTimeout); | 1173 ASSERT_EQ_SIMULATED_WAIT(5U, candidates_.size(), kDefaultAllocationTimeout, |
| 1174 fake_clock); |
| 1155 EXPECT_EQ(2U, ports_.size()); | 1175 EXPECT_EQ(2U, ports_.size()); |
| 1156 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); | 1176 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); |
| 1157 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); | 1177 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); |
| 1158 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); | 1178 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); |
| 1159 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); | 1179 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 1160 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", | 1180 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", |
| 1161 kRelaySslTcpIntAddr); | 1181 kRelaySslTcpIntAddr); |
| 1162 EXPECT_TRUE(candidate_allocation_done_); | 1182 EXPECT_TRUE(candidate_allocation_done_); |
| 1163 } | 1183 } |
| 1164 | 1184 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1175 // In case of Relay, ports creation will succeed but sockets will fail. | 1195 // In case of Relay, ports creation will succeed but sockets will fail. |
| 1176 // There is no error reporting from RelayEntry to handle this failure. | 1196 // There is no error reporting from RelayEntry to handle this failure. |
| 1177 } | 1197 } |
| 1178 | 1198 |
| 1179 // Testing STUN timeout. | 1199 // Testing STUN timeout. |
| 1180 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpAllowed) { | 1200 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpAllowed) { |
| 1181 fss_->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, kClientAddr); | 1201 fss_->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, kClientAddr); |
| 1182 AddInterface(kClientAddr); | 1202 AddInterface(kClientAddr); |
| 1183 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1203 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1184 session_->StartGettingPorts(); | 1204 session_->StartGettingPorts(); |
| 1185 EXPECT_EQ_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout); | 1205 EXPECT_EQ_SIMULATED_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout, |
| 1206 fake_clock); |
| 1186 EXPECT_EQ(2U, ports_.size()); | 1207 EXPECT_EQ(2U, ports_.size()); |
| 1187 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); | 1208 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1188 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); | 1209 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 1189 // RelayPort connection timeout is 3sec. TCP connection with RelayServer | 1210 // RelayPort connection timeout is 3sec. TCP connection with RelayServer |
| 1190 // will be tried after 3 seconds. | 1211 // will be tried after about 3 seconds. |
| 1191 // TODO(deadbeef): Use simulated clock here, waiting for exactly 3 seconds. | 1212 EXPECT_EQ_SIMULATED_WAIT(6U, candidates_.size(), 3500, fake_clock); |
| 1192 EXPECT_EQ_WAIT(6U, candidates_.size(), kStunTimeoutMs); | |
| 1193 EXPECT_EQ(3U, ports_.size()); | 1213 EXPECT_EQ(3U, ports_.size()); |
| 1194 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); | 1214 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); |
| 1195 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); | 1215 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); |
| 1196 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", | 1216 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", |
| 1197 kRelaySslTcpIntAddr); | 1217 kRelaySslTcpIntAddr); |
| 1198 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); | 1218 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); |
| 1199 // Stun Timeout is 9.5sec. | 1219 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1200 // TODO(deadbeef): Use simulated clock here, waiting exactly 6.5 seconds. | 1220 cricket::STUN_TOTAL_TIMEOUT, fake_clock); |
| 1201 EXPECT_TRUE_WAIT(candidate_allocation_done_, kStunTimeoutMs); | |
| 1202 } | 1221 } |
| 1203 | 1222 |
| 1204 TEST_F(BasicPortAllocatorTest, TestCandidatePriorityOfMultipleInterfaces) { | 1223 TEST_F(BasicPortAllocatorTest, TestCandidatePriorityOfMultipleInterfaces) { |
| 1205 AddInterface(kClientAddr); | 1224 AddInterface(kClientAddr); |
| 1206 AddInterface(kClientAddr2); | 1225 AddInterface(kClientAddr2); |
| 1207 // Allocating only host UDP ports. This is done purely for testing | 1226 // Allocating only host UDP ports. This is done purely for testing |
| 1208 // convenience. | 1227 // convenience. |
| 1209 allocator().set_flags(PORTALLOCATOR_DISABLE_TCP | PORTALLOCATOR_DISABLE_STUN | | 1228 allocator().set_flags(PORTALLOCATOR_DISABLE_TCP | PORTALLOCATOR_DISABLE_STUN | |
| 1210 PORTALLOCATOR_DISABLE_RELAY); | 1229 PORTALLOCATOR_DISABLE_RELAY); |
| 1211 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1230 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1212 session_->StartGettingPorts(); | 1231 session_->StartGettingPorts(); |
| 1213 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1232 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1233 kDefaultAllocationTimeout, fake_clock); |
| 1214 ASSERT_EQ(2U, candidates_.size()); | 1234 ASSERT_EQ(2U, candidates_.size()); |
| 1215 EXPECT_EQ(2U, ports_.size()); | 1235 EXPECT_EQ(2U, ports_.size()); |
| 1216 // Candidates priorities should be different. | 1236 // Candidates priorities should be different. |
| 1217 EXPECT_NE(candidates_[0].priority(), candidates_[1].priority()); | 1237 EXPECT_NE(candidates_[0].priority(), candidates_[1].priority()); |
| 1218 } | 1238 } |
| 1219 | 1239 |
| 1220 // Test to verify ICE restart process. | 1240 // Test to verify ICE restart process. |
| 1221 TEST_F(BasicPortAllocatorTest, TestGetAllPortsRestarts) { | 1241 TEST_F(BasicPortAllocatorTest, TestGetAllPortsRestarts) { |
| 1222 AddInterface(kClientAddr); | 1242 AddInterface(kClientAddr); |
| 1223 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1243 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1224 session_->StartGettingPorts(); | 1244 session_->StartGettingPorts(); |
| 1225 EXPECT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); | 1245 EXPECT_EQ_SIMULATED_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout, |
| 1246 fake_clock); |
| 1226 EXPECT_EQ(4U, ports_.size()); | 1247 EXPECT_EQ(4U, ports_.size()); |
| 1227 EXPECT_TRUE(candidate_allocation_done_); | 1248 EXPECT_TRUE(candidate_allocation_done_); |
| 1228 // TODO(deadbeef): Extend this to verify ICE restart. | 1249 // TODO(deadbeef): Extend this to verify ICE restart. |
| 1229 } | 1250 } |
| 1230 | 1251 |
| 1231 // Test that the allocator session uses the candidate filter it's created with, | 1252 // Test that the allocator session uses the candidate filter it's created with, |
| 1232 // rather than the filter of its parent allocator. | 1253 // rather than the filter of its parent allocator. |
| 1233 // The filter of the allocator should only affect the next gathering phase, | 1254 // The filter of the allocator should only affect the next gathering phase, |
| 1234 // according to JSEP, which means the *next* allocator session returned. | 1255 // according to JSEP, which means the *next* allocator session returned. |
| 1235 TEST_F(BasicPortAllocatorTest, TestSessionUsesOwnCandidateFilter) { | 1256 TEST_F(BasicPortAllocatorTest, TestSessionUsesOwnCandidateFilter) { |
| 1236 AddInterface(kClientAddr); | 1257 AddInterface(kClientAddr); |
| 1237 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1258 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1238 // Set candidate filter *after* creating the session. Should have no effect. | 1259 // Set candidate filter *after* creating the session. Should have no effect. |
| 1239 allocator().set_candidate_filter(CF_RELAY); | 1260 allocator().set_candidate_filter(CF_RELAY); |
| 1240 session_->StartGettingPorts(); | 1261 session_->StartGettingPorts(); |
| 1241 // 7 candidates and 4 ports is what we would normally get (see the | 1262 // 7 candidates and 4 ports is what we would normally get (see the |
| 1242 // TestGetAllPorts* tests). | 1263 // TestGetAllPorts* tests). |
| 1243 EXPECT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); | 1264 EXPECT_EQ_SIMULATED_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout, |
| 1265 fake_clock); |
| 1244 EXPECT_EQ(4U, ports_.size()); | 1266 EXPECT_EQ(4U, ports_.size()); |
| 1245 EXPECT_TRUE(candidate_allocation_done_); | 1267 EXPECT_TRUE(candidate_allocation_done_); |
| 1246 } | 1268 } |
| 1247 | 1269 |
| 1248 // Test ICE candidate filter mechanism with options Relay/Host/Reflexive. | 1270 // Test ICE candidate filter mechanism with options Relay/Host/Reflexive. |
| 1249 // This test also verifies that when the allocator is only allowed to use | 1271 // This test also verifies that when the allocator is only allowed to use |
| 1250 // relay (i.e. IceTransportsType is relay), the raddr is an empty | 1272 // relay (i.e. IceTransportsType is relay), the raddr is an empty |
| 1251 // address with the correct family. This is to prevent any local | 1273 // address with the correct family. This is to prevent any local |
| 1252 // reflective address leakage in the sdp line. | 1274 // reflective address leakage in the sdp line. |
| 1253 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithRelayOnly) { | 1275 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithRelayOnly) { |
| 1254 AddInterface(kClientAddr); | 1276 AddInterface(kClientAddr); |
| 1255 // GTURN is not configured here. | 1277 // GTURN is not configured here. |
| 1256 ResetWithTurnServersNoNat(kTurnUdpIntAddr, rtc::SocketAddress()); | 1278 ResetWithTurnServersNoNat(kTurnUdpIntAddr, rtc::SocketAddress()); |
| 1257 allocator().set_candidate_filter(CF_RELAY); | 1279 allocator().set_candidate_filter(CF_RELAY); |
| 1258 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1280 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1259 session_->StartGettingPorts(); | 1281 session_->StartGettingPorts(); |
| 1260 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1282 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1283 kDefaultAllocationTimeout, fake_clock); |
| 1261 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", | 1284 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", |
| 1262 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); | 1285 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); |
| 1263 | 1286 |
| 1264 EXPECT_EQ(1U, candidates_.size()); | 1287 EXPECT_EQ(1U, candidates_.size()); |
| 1265 EXPECT_EQ(1U, ports_.size()); // Only Relay port will be in ready state. | 1288 EXPECT_EQ(1U, ports_.size()); // Only Relay port will be in ready state. |
| 1266 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidates_[0].type()); | 1289 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidates_[0].type()); |
| 1267 EXPECT_EQ( | 1290 EXPECT_EQ( |
| 1268 candidates_[0].related_address(), | 1291 candidates_[0].related_address(), |
| 1269 rtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); | 1292 rtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); |
| 1270 } | 1293 } |
| 1271 | 1294 |
| 1272 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithHostOnly) { | 1295 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithHostOnly) { |
| 1273 AddInterface(kClientAddr); | 1296 AddInterface(kClientAddr); |
| 1274 allocator().set_flags(PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1297 allocator().set_flags(PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1275 allocator().set_candidate_filter(CF_HOST); | 1298 allocator().set_candidate_filter(CF_HOST); |
| 1276 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1299 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1277 session_->StartGettingPorts(); | 1300 session_->StartGettingPorts(); |
| 1278 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1301 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1302 kDefaultAllocationTimeout, fake_clock); |
| 1279 EXPECT_EQ(2U, candidates_.size()); // Host UDP/TCP candidates only. | 1303 EXPECT_EQ(2U, candidates_.size()); // Host UDP/TCP candidates only. |
| 1280 EXPECT_EQ(2U, ports_.size()); // UDP/TCP ports only. | 1304 EXPECT_EQ(2U, ports_.size()); // UDP/TCP ports only. |
| 1281 for (const Candidate& candidate : candidates_) { | 1305 for (const Candidate& candidate : candidates_) { |
| 1282 EXPECT_EQ(std::string(LOCAL_PORT_TYPE), candidate.type()); | 1306 EXPECT_EQ(std::string(LOCAL_PORT_TYPE), candidate.type()); |
| 1283 } | 1307 } |
| 1284 } | 1308 } |
| 1285 | 1309 |
| 1286 // Host is behind the NAT. | 1310 // Host is behind the NAT. |
| 1287 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithReflexiveOnly) { | 1311 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithReflexiveOnly) { |
| 1288 AddInterface(kPrivateAddr); | 1312 AddInterface(kPrivateAddr); |
| 1289 ResetWithStunServerAndNat(kStunAddr); | 1313 ResetWithStunServerAndNat(kStunAddr); |
| 1290 | 1314 |
| 1291 allocator().set_flags(PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1315 allocator().set_flags(PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1292 allocator().set_candidate_filter(CF_REFLEXIVE); | 1316 allocator().set_candidate_filter(CF_REFLEXIVE); |
| 1293 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1317 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1294 session_->StartGettingPorts(); | 1318 session_->StartGettingPorts(); |
| 1295 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1319 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1320 kDefaultAllocationTimeout, fake_clock); |
| 1296 // Host is behind NAT, no private address will be exposed. Hence only UDP | 1321 // Host is behind NAT, no private address will be exposed. Hence only UDP |
| 1297 // port with STUN candidate will be sent outside. | 1322 // port with STUN candidate will be sent outside. |
| 1298 EXPECT_EQ(1U, candidates_.size()); // Only STUN candidate. | 1323 EXPECT_EQ(1U, candidates_.size()); // Only STUN candidate. |
| 1299 EXPECT_EQ(1U, ports_.size()); // Only UDP port will be in ready state. | 1324 EXPECT_EQ(1U, ports_.size()); // Only UDP port will be in ready state. |
| 1300 EXPECT_EQ(std::string(STUN_PORT_TYPE), candidates_[0].type()); | 1325 EXPECT_EQ(std::string(STUN_PORT_TYPE), candidates_[0].type()); |
| 1301 EXPECT_EQ( | 1326 EXPECT_EQ( |
| 1302 candidates_[0].related_address(), | 1327 candidates_[0].related_address(), |
| 1303 rtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); | 1328 rtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); |
| 1304 } | 1329 } |
| 1305 | 1330 |
| 1306 // Host is not behind the NAT. | 1331 // Host is not behind the NAT. |
| 1307 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithReflexiveOnlyAndNoNAT) { | 1332 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithReflexiveOnlyAndNoNAT) { |
| 1308 AddInterface(kClientAddr); | 1333 AddInterface(kClientAddr); |
| 1309 allocator().set_flags(PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1334 allocator().set_flags(PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1310 allocator().set_candidate_filter(CF_REFLEXIVE); | 1335 allocator().set_candidate_filter(CF_REFLEXIVE); |
| 1311 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1336 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1312 session_->StartGettingPorts(); | 1337 session_->StartGettingPorts(); |
| 1313 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1338 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1339 kDefaultAllocationTimeout, fake_clock); |
| 1314 // Host has a public address, both UDP and TCP candidates will be exposed. | 1340 // Host has a public address, both UDP and TCP candidates will be exposed. |
| 1315 EXPECT_EQ(2U, candidates_.size()); // Local UDP + TCP candidate. | 1341 EXPECT_EQ(2U, candidates_.size()); // Local UDP + TCP candidate. |
| 1316 EXPECT_EQ(2U, ports_.size()); // UDP and TCP ports will be in ready state. | 1342 EXPECT_EQ(2U, ports_.size()); // UDP and TCP ports will be in ready state. |
| 1317 for (const Candidate& candidate : candidates_) { | 1343 for (const Candidate& candidate : candidates_) { |
| 1318 EXPECT_EQ(std::string(LOCAL_PORT_TYPE), candidate.type()); | 1344 EXPECT_EQ(std::string(LOCAL_PORT_TYPE), candidate.type()); |
| 1319 } | 1345 } |
| 1320 } | 1346 } |
| 1321 | 1347 |
| 1322 // Test that we get the same ufrag and pwd for all candidates. | 1348 // Test that we get the same ufrag and pwd for all candidates. |
| 1323 TEST_F(BasicPortAllocatorTest, TestEnableSharedUfrag) { | 1349 TEST_F(BasicPortAllocatorTest, TestEnableSharedUfrag) { |
| 1324 AddInterface(kClientAddr); | 1350 AddInterface(kClientAddr); |
| 1325 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1351 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1326 session_->StartGettingPorts(); | 1352 session_->StartGettingPorts(); |
| 1327 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); | 1353 ASSERT_EQ_SIMULATED_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout, |
| 1354 fake_clock); |
| 1328 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); | 1355 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1329 EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", kClientAddr); | 1356 EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", kClientAddr); |
| 1330 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); | 1357 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 1331 EXPECT_EQ(4U, ports_.size()); | 1358 EXPECT_EQ(4U, ports_.size()); |
| 1332 for (const Candidate& candidate : candidates_) { | 1359 for (const Candidate& candidate : candidates_) { |
| 1333 EXPECT_EQ(kIceUfrag0, candidate.username()); | 1360 EXPECT_EQ(kIceUfrag0, candidate.username()); |
| 1334 EXPECT_EQ(kIcePwd0, candidate.password()); | 1361 EXPECT_EQ(kIcePwd0, candidate.password()); |
| 1335 } | 1362 } |
| 1336 EXPECT_TRUE(candidate_allocation_done_); | 1363 EXPECT_TRUE(candidate_allocation_done_); |
| 1337 } | 1364 } |
| 1338 | 1365 |
| 1339 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port | 1366 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port |
| 1340 // is allocated for udp and stun. Also verify there is only one candidate | 1367 // is allocated for udp and stun. Also verify there is only one candidate |
| 1341 // (local) if stun candidate is same as local candidate, which will be the case | 1368 // (local) if stun candidate is same as local candidate, which will be the case |
| 1342 // in a public network like the below test. | 1369 // in a public network like the below test. |
| 1343 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithoutNat) { | 1370 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithoutNat) { |
| 1344 AddInterface(kClientAddr); | 1371 AddInterface(kClientAddr); |
| 1345 allocator_->set_flags(allocator().flags() | | 1372 allocator_->set_flags(allocator().flags() | |
| 1346 PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1373 PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1347 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1374 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1348 session_->StartGettingPorts(); | 1375 session_->StartGettingPorts(); |
| 1349 ASSERT_EQ_WAIT(6U, candidates_.size(), kDefaultAllocationTimeout); | 1376 ASSERT_EQ_SIMULATED_WAIT(6U, candidates_.size(), kDefaultAllocationTimeout, |
| 1377 fake_clock); |
| 1350 EXPECT_EQ(3U, ports_.size()); | 1378 EXPECT_EQ(3U, ports_.size()); |
| 1351 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); | 1379 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1352 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1380 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1381 kDefaultAllocationTimeout, fake_clock); |
| 1353 } | 1382 } |
| 1354 | 1383 |
| 1355 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port | 1384 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port |
| 1356 // is allocated for udp and stun. In this test we should expect both stun and | 1385 // is allocated for udp and stun. In this test we should expect both stun and |
| 1357 // local candidates as client behind a nat. | 1386 // local candidates as client behind a nat. |
| 1358 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNat) { | 1387 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNat) { |
| 1359 AddInterface(kClientAddr); | 1388 AddInterface(kClientAddr); |
| 1360 ResetWithStunServerAndNat(kStunAddr); | 1389 ResetWithStunServerAndNat(kStunAddr); |
| 1361 | 1390 |
| 1362 allocator_->set_flags(allocator().flags() | | 1391 allocator_->set_flags(allocator().flags() | |
| 1363 PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1392 PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1364 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1393 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1365 session_->StartGettingPorts(); | 1394 session_->StartGettingPorts(); |
| 1366 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 1395 ASSERT_EQ_SIMULATED_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout, |
| 1396 fake_clock); |
| 1367 ASSERT_EQ(2U, ports_.size()); | 1397 ASSERT_EQ(2U, ports_.size()); |
| 1368 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); | 1398 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1369 EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", | 1399 EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", |
| 1370 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); | 1400 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); |
| 1371 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1401 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1402 kDefaultAllocationTimeout, fake_clock); |
| 1372 EXPECT_EQ(3U, candidates_.size()); | 1403 EXPECT_EQ(3U, candidates_.size()); |
| 1373 } | 1404 } |
| 1374 | 1405 |
| 1375 // Test TURN port in shared socket mode with UDP and TCP TURN server addresses. | 1406 // Test TURN port in shared socket mode with UDP and TCP TURN server addresses. |
| 1376 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithoutNatUsingTurn) { | 1407 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithoutNatUsingTurn) { |
| 1377 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); | 1408 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); |
| 1378 AddInterface(kClientAddr); | 1409 AddInterface(kClientAddr); |
| 1379 allocator_.reset(new BasicPortAllocator(&network_manager_)); | 1410 allocator_.reset(new BasicPortAllocator(&network_manager_)); |
| 1380 | 1411 |
| 1381 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); | 1412 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); |
| 1382 | 1413 |
| 1383 allocator_->set_step_delay(kMinimumStepDelay); | 1414 allocator_->set_step_delay(kMinimumStepDelay); |
| 1384 allocator_->set_flags(allocator().flags() | | 1415 allocator_->set_flags(allocator().flags() | |
| 1385 PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 1416 PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 1386 PORTALLOCATOR_DISABLE_TCP); | 1417 PORTALLOCATOR_DISABLE_TCP); |
| 1387 | 1418 |
| 1388 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1419 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1389 session_->StartGettingPorts(); | 1420 session_->StartGettingPorts(); |
| 1390 | 1421 |
| 1391 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 1422 ASSERT_EQ_SIMULATED_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout, |
| 1423 fake_clock); |
| 1392 ASSERT_EQ(3U, ports_.size()); | 1424 ASSERT_EQ(3U, ports_.size()); |
| 1393 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); | 1425 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1394 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", | 1426 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", |
| 1395 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); | 1427 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); |
| 1396 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", | 1428 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", |
| 1397 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); | 1429 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); |
| 1398 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1430 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1431 kDefaultAllocationTimeout, fake_clock); |
| 1399 EXPECT_EQ(3U, candidates_.size()); | 1432 EXPECT_EQ(3U, candidates_.size()); |
| 1400 } | 1433 } |
| 1401 | 1434 |
| 1402 // Test that if prune_turn_ports is set, TCP TURN port will not be used | 1435 // Test that if prune_turn_ports is set, TCP TURN port will not be used |
| 1403 // if UDP TurnPort is used, given that TCP TURN port becomes ready first. | 1436 // if UDP TurnPort is used, given that TCP TURN port becomes ready first. |
| 1404 TEST_F(BasicPortAllocatorTest, | 1437 TEST_F(BasicPortAllocatorTest, |
| 1405 TestUdpTurnPortPrunesTcpTurnPortWithTcpPortReadyFirst) { | 1438 TestUdpTurnPortPrunesTcpTurnPortWithTcpPortReadyFirst) { |
| 1406 // UDP has longer delay than TCP so that TCP TURN port becomes ready first. | 1439 // UDP has longer delay than TCP so that TCP TURN port becomes ready first. |
| 1407 virtual_socket_server()->SetDelayOnAddress(kTurnUdpIntAddr, 200); | 1440 virtual_socket_server()->SetDelayOnAddress(kTurnUdpIntAddr, 200); |
| 1408 virtual_socket_server()->SetDelayOnAddress(kTurnTcpIntAddr, 100); | 1441 virtual_socket_server()->SetDelayOnAddress(kTurnTcpIntAddr, 100); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 allocator_->AddTurnServer(turn_server); | 1515 allocator_->AddTurnServer(turn_server); |
| 1483 | 1516 |
| 1484 allocator_->set_step_delay(kMinimumStepDelay); | 1517 allocator_->set_step_delay(kMinimumStepDelay); |
| 1485 allocator_->set_flags(allocator().flags() | | 1518 allocator_->set_flags(allocator().flags() | |
| 1486 PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 1519 PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 1487 PORTALLOCATOR_DISABLE_TCP); | 1520 PORTALLOCATOR_DISABLE_TCP); |
| 1488 | 1521 |
| 1489 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1522 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1490 session_->StartGettingPorts(); | 1523 session_->StartGettingPorts(); |
| 1491 | 1524 |
| 1492 EXPECT_EQ_WAIT(2U, ports_.size(), kDefaultAllocationTimeout); | 1525 EXPECT_EQ_SIMULATED_WAIT(2U, ports_.size(), kDefaultAllocationTimeout, |
| 1526 fake_clock); |
| 1493 } | 1527 } |
| 1494 | 1528 |
| 1495 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port | 1529 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port |
| 1496 // is allocated for udp/stun/turn. In this test we should expect all local, | 1530 // is allocated for udp/stun/turn. In this test we should expect all local, |
| 1497 // stun and turn candidates. | 1531 // stun and turn candidates. |
| 1498 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurn) { | 1532 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurn) { |
| 1499 AddInterface(kClientAddr); | 1533 AddInterface(kClientAddr); |
| 1500 ResetWithStunServerAndNat(kStunAddr); | 1534 ResetWithStunServerAndNat(kStunAddr); |
| 1501 | 1535 |
| 1502 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); | 1536 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |
| 1503 | 1537 |
| 1504 allocator_->set_flags(allocator().flags() | | 1538 allocator_->set_flags(allocator().flags() | |
| 1505 PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 1539 PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 1506 PORTALLOCATOR_DISABLE_TCP); | 1540 PORTALLOCATOR_DISABLE_TCP); |
| 1507 | 1541 |
| 1508 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1542 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1509 session_->StartGettingPorts(); | 1543 session_->StartGettingPorts(); |
| 1510 | 1544 |
| 1511 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 1545 ASSERT_EQ_SIMULATED_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout, |
| 1546 fake_clock); |
| 1512 ASSERT_EQ(2U, ports_.size()); | 1547 ASSERT_EQ(2U, ports_.size()); |
| 1513 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); | 1548 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1514 EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", | 1549 EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", |
| 1515 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); | 1550 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); |
| 1516 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", | 1551 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", |
| 1517 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); | 1552 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); |
| 1518 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1553 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1554 kDefaultAllocationTimeout, fake_clock); |
| 1519 EXPECT_EQ(3U, candidates_.size()); | 1555 EXPECT_EQ(3U, candidates_.size()); |
| 1520 // Local port will be created first and then TURN port. | 1556 // Local port will be created first and then TURN port. |
| 1521 EXPECT_EQ(2U, ports_[0]->Candidates().size()); | 1557 EXPECT_EQ(2U, ports_[0]->Candidates().size()); |
| 1522 EXPECT_EQ(1U, ports_[1]->Candidates().size()); | 1558 EXPECT_EQ(1U, ports_[1]->Candidates().size()); |
| 1523 } | 1559 } |
| 1524 | 1560 |
| 1525 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled and the TURN | 1561 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled and the TURN |
| 1526 // server is also used as the STUN server, we should get 'local', 'stun', and | 1562 // server is also used as the STUN server, we should get 'local', 'stun', and |
| 1527 // 'relay' candidates. | 1563 // 'relay' candidates. |
| 1528 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnAsStun) { | 1564 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnAsStun) { |
| 1529 AddInterface(kClientAddr); | 1565 AddInterface(kClientAddr); |
| 1530 // Use an empty SocketAddress to add a NAT without STUN server. | 1566 // Use an empty SocketAddress to add a NAT without STUN server. |
| 1531 ResetWithStunServerAndNat(SocketAddress()); | 1567 ResetWithStunServerAndNat(SocketAddress()); |
| 1532 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); | 1568 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |
| 1533 | 1569 |
| 1534 // Must set the step delay to 0 to make sure the relay allocation phase is | 1570 // Must set the step delay to 0 to make sure the relay allocation phase is |
| 1535 // started before the STUN candidates are obtained, so that the STUN binding | 1571 // started before the STUN candidates are obtained, so that the STUN binding |
| 1536 // response is processed when both StunPort and TurnPort exist to reproduce | 1572 // response is processed when both StunPort and TurnPort exist to reproduce |
| 1537 // webrtc issue 3537. | 1573 // webrtc issue 3537. |
| 1538 allocator_->set_step_delay(0); | 1574 allocator_->set_step_delay(0); |
| 1539 allocator_->set_flags(allocator().flags() | | 1575 allocator_->set_flags(allocator().flags() | |
| 1540 PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 1576 PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 1541 PORTALLOCATOR_DISABLE_TCP); | 1577 PORTALLOCATOR_DISABLE_TCP); |
| 1542 | 1578 |
| 1543 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1579 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1544 session_->StartGettingPorts(); | 1580 session_->StartGettingPorts(); |
| 1545 | 1581 |
| 1546 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 1582 ASSERT_EQ_SIMULATED_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout, |
| 1583 fake_clock); |
| 1547 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); | 1584 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1548 Candidate stun_candidate; | 1585 Candidate stun_candidate; |
| 1549 EXPECT_PRED5(FindCandidate, candidates_, "stun", "udp", | 1586 EXPECT_PRED5(FindCandidate, candidates_, "stun", "udp", |
| 1550 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0), &stun_candidate); | 1587 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0), &stun_candidate); |
| 1551 EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp", | 1588 EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp", |
| 1552 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0), | 1589 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0), |
| 1553 stun_candidate.address()); | 1590 stun_candidate.address()); |
| 1554 | 1591 |
| 1555 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1592 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1593 kDefaultAllocationTimeout, fake_clock); |
| 1556 EXPECT_EQ(3U, candidates_.size()); | 1594 EXPECT_EQ(3U, candidates_.size()); |
| 1557 // Local port will be created first and then TURN port. | 1595 // Local port will be created first and then TURN port. |
| 1558 EXPECT_EQ(2U, ports_[0]->Candidates().size()); | 1596 EXPECT_EQ(2U, ports_[0]->Candidates().size()); |
| 1559 EXPECT_EQ(1U, ports_[1]->Candidates().size()); | 1597 EXPECT_EQ(1U, ports_[1]->Candidates().size()); |
| 1560 } | 1598 } |
| 1561 | 1599 |
| 1562 // Test that when only a TCP TURN server is available, we do NOT use it as | 1600 // Test that when only a TCP TURN server is available, we do NOT use it as |
| 1563 // a UDP STUN server, as this could leak our IP address. Thus we should only | 1601 // a UDP STUN server, as this could leak our IP address. Thus we should only |
| 1564 // expect two ports, a UDPPort and TurnPort. | 1602 // expect two ports, a UDPPort and TurnPort. |
| 1565 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnTcpOnly) { | 1603 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnTcpOnly) { |
| 1566 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); | 1604 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); |
| 1567 AddInterface(kClientAddr); | 1605 AddInterface(kClientAddr); |
| 1568 ResetWithStunServerAndNat(rtc::SocketAddress()); | 1606 ResetWithStunServerAndNat(rtc::SocketAddress()); |
| 1569 AddTurnServers(rtc::SocketAddress(), kTurnTcpIntAddr); | 1607 AddTurnServers(rtc::SocketAddress(), kTurnTcpIntAddr); |
| 1570 | 1608 |
| 1571 allocator_->set_flags(allocator().flags() | | 1609 allocator_->set_flags(allocator().flags() | |
| 1572 PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 1610 PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 1573 PORTALLOCATOR_DISABLE_TCP); | 1611 PORTALLOCATOR_DISABLE_TCP); |
| 1574 | 1612 |
| 1575 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1613 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1576 session_->StartGettingPorts(); | 1614 session_->StartGettingPorts(); |
| 1577 | 1615 |
| 1578 ASSERT_EQ_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout); | 1616 ASSERT_EQ_SIMULATED_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout, |
| 1617 fake_clock); |
| 1579 ASSERT_EQ(2U, ports_.size()); | 1618 ASSERT_EQ(2U, ports_.size()); |
| 1580 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); | 1619 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1581 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", | 1620 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", |
| 1582 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); | 1621 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); |
| 1583 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1622 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1623 kDefaultAllocationTimeout, fake_clock); |
| 1584 EXPECT_EQ(2U, candidates_.size()); | 1624 EXPECT_EQ(2U, candidates_.size()); |
| 1585 EXPECT_EQ(1U, ports_[0]->Candidates().size()); | 1625 EXPECT_EQ(1U, ports_[0]->Candidates().size()); |
| 1586 EXPECT_EQ(1U, ports_[1]->Candidates().size()); | 1626 EXPECT_EQ(1U, ports_[1]->Candidates().size()); |
| 1587 } | 1627 } |
| 1588 | 1628 |
| 1589 // Test that even when PORTALLOCATOR_ENABLE_SHARED_SOCKET is NOT enabled, the | 1629 // Test that even when PORTALLOCATOR_ENABLE_SHARED_SOCKET is NOT enabled, the |
| 1590 // TURN server is used as the STUN server and we get 'local', 'stun', and | 1630 // TURN server is used as the STUN server and we get 'local', 'stun', and |
| 1591 // 'relay' candidates. | 1631 // 'relay' candidates. |
| 1592 // TODO(deadbeef): Remove this test when support for non-shared socket mode | 1632 // TODO(deadbeef): Remove this test when support for non-shared socket mode |
| 1593 // is removed. | 1633 // is removed. |
| 1594 TEST_F(BasicPortAllocatorTest, TestNonSharedSocketWithNatUsingTurnAsStun) { | 1634 TEST_F(BasicPortAllocatorTest, TestNonSharedSocketWithNatUsingTurnAsStun) { |
| 1595 AddInterface(kClientAddr); | 1635 AddInterface(kClientAddr); |
| 1596 // Use an empty SocketAddress to add a NAT without STUN server. | 1636 // Use an empty SocketAddress to add a NAT without STUN server. |
| 1597 ResetWithStunServerAndNat(SocketAddress()); | 1637 ResetWithStunServerAndNat(SocketAddress()); |
| 1598 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); | 1638 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |
| 1599 | 1639 |
| 1600 allocator_->set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_TCP); | 1640 allocator_->set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_TCP); |
| 1601 | 1641 |
| 1602 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1642 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1603 session_->StartGettingPorts(); | 1643 session_->StartGettingPorts(); |
| 1604 | 1644 |
| 1605 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 1645 ASSERT_EQ_SIMULATED_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout, |
| 1646 fake_clock); |
| 1606 ASSERT_EQ(3U, ports_.size()); | 1647 ASSERT_EQ(3U, ports_.size()); |
| 1607 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); | 1648 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1608 Candidate stun_candidate; | 1649 Candidate stun_candidate; |
| 1609 EXPECT_PRED5(FindCandidate, candidates_, "stun", "udp", | 1650 EXPECT_PRED5(FindCandidate, candidates_, "stun", "udp", |
| 1610 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0), &stun_candidate); | 1651 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0), &stun_candidate); |
| 1611 Candidate turn_candidate; | 1652 Candidate turn_candidate; |
| 1612 EXPECT_PRED5(FindCandidate, candidates_, "relay", "udp", | 1653 EXPECT_PRED5(FindCandidate, candidates_, "relay", "udp", |
| 1613 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0), | 1654 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0), |
| 1614 &turn_candidate); | 1655 &turn_candidate); |
| 1615 // Not using shared socket, so the STUN request's server reflexive address | 1656 // Not using shared socket, so the STUN request's server reflexive address |
| 1616 // should be different than the TURN request's server reflexive address. | 1657 // should be different than the TURN request's server reflexive address. |
| 1617 EXPECT_NE(turn_candidate.related_address(), stun_candidate.address()); | 1658 EXPECT_NE(turn_candidate.related_address(), stun_candidate.address()); |
| 1618 | 1659 |
| 1619 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1660 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1661 kDefaultAllocationTimeout, fake_clock); |
| 1620 EXPECT_EQ(3U, candidates_.size()); | 1662 EXPECT_EQ(3U, candidates_.size()); |
| 1621 EXPECT_EQ(1U, ports_[0]->Candidates().size()); | 1663 EXPECT_EQ(1U, ports_[0]->Candidates().size()); |
| 1622 EXPECT_EQ(1U, ports_[1]->Candidates().size()); | 1664 EXPECT_EQ(1U, ports_[1]->Candidates().size()); |
| 1623 EXPECT_EQ(1U, ports_[2]->Candidates().size()); | 1665 EXPECT_EQ(1U, ports_[2]->Candidates().size()); |
| 1624 } | 1666 } |
| 1625 | 1667 |
| 1626 // Test that even when both a STUN and TURN server are configured, the TURN | 1668 // Test that even when both a STUN and TURN server are configured, the TURN |
| 1627 // server is used as a STUN server and we get a 'stun' candidate. | 1669 // server is used as a STUN server and we get a 'stun' candidate. |
| 1628 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnAndStun) { | 1670 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnAndStun) { |
| 1629 AddInterface(kClientAddr); | 1671 AddInterface(kClientAddr); |
| 1630 // Configure with STUN server but destroy it, so we can ensure that it's | 1672 // Configure with STUN server but destroy it, so we can ensure that it's |
| 1631 // the TURN server actually being used as a STUN server. | 1673 // the TURN server actually being used as a STUN server. |
| 1632 ResetWithStunServerAndNat(kStunAddr); | 1674 ResetWithStunServerAndNat(kStunAddr); |
| 1633 stun_server_.reset(); | 1675 stun_server_.reset(); |
| 1634 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); | 1676 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |
| 1635 | 1677 |
| 1636 allocator_->set_flags(allocator().flags() | | 1678 allocator_->set_flags(allocator().flags() | |
| 1637 PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 1679 PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 1638 PORTALLOCATOR_DISABLE_TCP); | 1680 PORTALLOCATOR_DISABLE_TCP); |
| 1639 | 1681 |
| 1640 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1682 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1641 session_->StartGettingPorts(); | 1683 session_->StartGettingPorts(); |
| 1642 | 1684 |
| 1643 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 1685 ASSERT_EQ_SIMULATED_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout, |
| 1686 fake_clock); |
| 1644 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); | 1687 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1645 Candidate stun_candidate; | 1688 Candidate stun_candidate; |
| 1646 EXPECT_PRED5(FindCandidate, candidates_, "stun", "udp", | 1689 EXPECT_PRED5(FindCandidate, candidates_, "stun", "udp", |
| 1647 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0), &stun_candidate); | 1690 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0), &stun_candidate); |
| 1648 EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp", | 1691 EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp", |
| 1649 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0), | 1692 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0), |
| 1650 stun_candidate.address()); | 1693 stun_candidate.address()); |
| 1651 | 1694 |
| 1652 // Don't bother waiting for STUN timeout, since we already verified | 1695 // Don't bother waiting for STUN timeout, since we already verified |
| 1653 // that we got a STUN candidate from the TURN server. | 1696 // that we got a STUN candidate from the TURN server. |
| 1654 } | 1697 } |
| 1655 | 1698 |
| 1656 // This test verifies when PORTALLOCATOR_ENABLE_SHARED_SOCKET flag is enabled | 1699 // This test verifies when PORTALLOCATOR_ENABLE_SHARED_SOCKET flag is enabled |
| 1657 // and fail to generate STUN candidate, local UDP candidate is generated | 1700 // and fail to generate STUN candidate, local UDP candidate is generated |
| 1658 // properly. | 1701 // properly. |
| 1659 TEST_F(BasicPortAllocatorTest, TestSharedSocketNoUdpAllowed) { | 1702 TEST_F(BasicPortAllocatorTest, TestSharedSocketNoUdpAllowed) { |
| 1660 allocator().set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_RELAY | | 1703 allocator().set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_RELAY | |
| 1661 PORTALLOCATOR_DISABLE_TCP | | 1704 PORTALLOCATOR_DISABLE_TCP | |
| 1662 PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1705 PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1663 fss_->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, kClientAddr); | 1706 fss_->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, kClientAddr); |
| 1664 AddInterface(kClientAddr); | 1707 AddInterface(kClientAddr); |
| 1665 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1708 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1666 session_->StartGettingPorts(); | 1709 session_->StartGettingPorts(); |
| 1667 ASSERT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout); | 1710 ASSERT_EQ_SIMULATED_WAIT(1U, ports_.size(), kDefaultAllocationTimeout, |
| 1711 fake_clock); |
| 1668 EXPECT_EQ(1U, candidates_.size()); | 1712 EXPECT_EQ(1U, candidates_.size()); |
| 1669 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); | 1713 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1670 // STUN timeout is 9.5sec. We need to wait to get candidate done signal. | 1714 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1671 EXPECT_TRUE_WAIT(candidate_allocation_done_, kStunTimeoutMs); | 1715 cricket::STUN_TOTAL_TIMEOUT, fake_clock); |
| 1672 EXPECT_EQ(1U, candidates_.size()); | 1716 EXPECT_EQ(1U, candidates_.size()); |
| 1673 } | 1717 } |
| 1674 | 1718 |
| 1675 // Test that when the NetworkManager doesn't have permission to enumerate | 1719 // Test that when the NetworkManager doesn't have permission to enumerate |
| 1676 // adapters, the PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified | 1720 // adapters, the PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified |
| 1677 // automatically. | 1721 // automatically. |
| 1678 TEST_F(BasicPortAllocatorTest, TestNetworkPermissionBlocked) { | 1722 TEST_F(BasicPortAllocatorTest, TestNetworkPermissionBlocked) { |
| 1679 network_manager_.set_default_local_addresses(kPrivateAddr.ipaddr(), | 1723 network_manager_.set_default_local_addresses(kPrivateAddr.ipaddr(), |
| 1680 rtc::IPAddress()); | 1724 rtc::IPAddress()); |
| 1681 network_manager_.set_enumeration_permission( | 1725 network_manager_.set_enumeration_permission( |
| 1682 rtc::NetworkManager::ENUMERATION_BLOCKED); | 1726 rtc::NetworkManager::ENUMERATION_BLOCKED); |
| 1683 allocator().set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_RELAY | | 1727 allocator().set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_RELAY | |
| 1684 PORTALLOCATOR_DISABLE_TCP | | 1728 PORTALLOCATOR_DISABLE_TCP | |
| 1685 PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1729 PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1686 EXPECT_EQ(0U, | 1730 EXPECT_EQ(0U, |
| 1687 allocator_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); | 1731 allocator_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); |
| 1688 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1732 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1689 EXPECT_EQ(0U, session_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); | 1733 EXPECT_EQ(0U, session_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); |
| 1690 session_->StartGettingPorts(); | 1734 session_->StartGettingPorts(); |
| 1691 EXPECT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout); | 1735 EXPECT_EQ_SIMULATED_WAIT(1U, ports_.size(), kDefaultAllocationTimeout, |
| 1736 fake_clock); |
| 1692 EXPECT_EQ(1U, candidates_.size()); | 1737 EXPECT_EQ(1U, candidates_.size()); |
| 1693 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kPrivateAddr); | 1738 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kPrivateAddr); |
| 1694 EXPECT_NE(0U, session_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); | 1739 EXPECT_NE(0U, session_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); |
| 1695 } | 1740 } |
| 1696 | 1741 |
| 1697 // This test verifies allocator can use IPv6 addresses along with IPv4. | 1742 // This test verifies allocator can use IPv6 addresses along with IPv4. |
| 1698 TEST_F(BasicPortAllocatorTest, TestEnableIPv6Addresses) { | 1743 TEST_F(BasicPortAllocatorTest, TestEnableIPv6Addresses) { |
| 1699 allocator().set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_RELAY | | 1744 allocator().set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_RELAY | |
| 1700 PORTALLOCATOR_ENABLE_IPV6 | | 1745 PORTALLOCATOR_ENABLE_IPV6 | |
| 1701 PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1746 PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1702 AddInterface(kClientIPv6Addr); | 1747 AddInterface(kClientIPv6Addr); |
| 1703 AddInterface(kClientAddr); | 1748 AddInterface(kClientAddr); |
| 1704 allocator_->set_step_delay(kMinimumStepDelay); | 1749 allocator_->set_step_delay(kMinimumStepDelay); |
| 1705 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1750 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1706 session_->StartGettingPorts(); | 1751 session_->StartGettingPorts(); |
| 1707 ASSERT_EQ_WAIT(4U, ports_.size(), kDefaultAllocationTimeout); | 1752 ASSERT_EQ_SIMULATED_WAIT(4U, ports_.size(), kDefaultAllocationTimeout, |
| 1753 fake_clock); |
| 1708 EXPECT_EQ(4U, candidates_.size()); | 1754 EXPECT_EQ(4U, candidates_.size()); |
| 1709 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1755 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1756 kDefaultAllocationTimeout, fake_clock); |
| 1710 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientIPv6Addr); | 1757 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientIPv6Addr); |
| 1711 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); | 1758 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1712 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientIPv6Addr); | 1759 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientIPv6Addr); |
| 1713 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); | 1760 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 1714 EXPECT_EQ(4U, candidates_.size()); | 1761 EXPECT_EQ(4U, candidates_.size()); |
| 1715 } | 1762 } |
| 1716 | 1763 |
| 1717 TEST_F(BasicPortAllocatorTest, TestStopGettingPorts) { | 1764 TEST_F(BasicPortAllocatorTest, TestStopGettingPorts) { |
| 1718 AddInterface(kClientAddr); | 1765 AddInterface(kClientAddr); |
| 1719 allocator_->set_step_delay(kDefaultStepDelay); | 1766 allocator_->set_step_delay(kDefaultStepDelay); |
| 1720 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1767 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1721 session_->StartGettingPorts(); | 1768 session_->StartGettingPorts(); |
| 1722 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); | 1769 ASSERT_EQ_SIMULATED_WAIT(2U, candidates_.size(), 1000, fake_clock); |
| 1723 EXPECT_EQ(2U, ports_.size()); | 1770 EXPECT_EQ(2U, ports_.size()); |
| 1724 session_->StopGettingPorts(); | 1771 session_->StopGettingPorts(); |
| 1725 EXPECT_TRUE_WAIT(candidate_allocation_done_, 1000); | 1772 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, 1000, fake_clock); |
| 1726 | 1773 |
| 1727 // After stopping getting ports, adding a new interface will not start | 1774 // After stopping getting ports, adding a new interface will not start |
| 1728 // getting ports again. | 1775 // getting ports again. |
| 1729 allocator_->set_step_delay(kMinimumStepDelay); | 1776 allocator_->set_step_delay(kMinimumStepDelay); |
| 1730 candidates_.clear(); | 1777 candidates_.clear(); |
| 1731 ports_.clear(); | 1778 ports_.clear(); |
| 1732 candidate_allocation_done_ = false; | 1779 candidate_allocation_done_ = false; |
| 1733 network_manager_.AddInterface(kClientAddr2); | 1780 network_manager_.AddInterface(kClientAddr2); |
| 1734 rtc::Thread::Current()->ProcessMessages(1000); | 1781 fake_clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(1000)); |
| 1735 EXPECT_EQ(0U, candidates_.size()); | 1782 EXPECT_EQ(0U, candidates_.size()); |
| 1736 EXPECT_EQ(0U, ports_.size()); | 1783 EXPECT_EQ(0U, ports_.size()); |
| 1737 } | 1784 } |
| 1738 | 1785 |
| 1739 TEST_F(BasicPortAllocatorTest, TestClearGettingPorts) { | 1786 TEST_F(BasicPortAllocatorTest, TestClearGettingPorts) { |
| 1740 AddInterface(kClientAddr); | 1787 AddInterface(kClientAddr); |
| 1741 allocator_->set_step_delay(kDefaultStepDelay); | 1788 allocator_->set_step_delay(kDefaultStepDelay); |
| 1742 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1789 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1743 session_->StartGettingPorts(); | 1790 session_->StartGettingPorts(); |
| 1744 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); | 1791 ASSERT_EQ_SIMULATED_WAIT(2U, candidates_.size(), 1000, fake_clock); |
| 1745 EXPECT_EQ(2U, ports_.size()); | 1792 EXPECT_EQ(2U, ports_.size()); |
| 1746 session_->ClearGettingPorts(); | 1793 session_->ClearGettingPorts(); |
| 1747 EXPECT_TRUE_WAIT(candidate_allocation_done_, 1000); | 1794 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, 1000, fake_clock); |
| 1748 | 1795 |
| 1749 // After clearing getting ports, adding a new interface will start getting | 1796 // After clearing getting ports, adding a new interface will start getting |
| 1750 // ports again. | 1797 // ports again. |
| 1751 allocator_->set_step_delay(kMinimumStepDelay); | 1798 allocator_->set_step_delay(kMinimumStepDelay); |
| 1752 candidates_.clear(); | 1799 candidates_.clear(); |
| 1753 ports_.clear(); | 1800 ports_.clear(); |
| 1754 candidate_allocation_done_ = false; | 1801 candidate_allocation_done_ = false; |
| 1755 network_manager_.AddInterface(kClientAddr2); | 1802 network_manager_.AddInterface(kClientAddr2); |
| 1756 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); | 1803 ASSERT_EQ_SIMULATED_WAIT(2U, candidates_.size(), 1000, fake_clock); |
| 1757 EXPECT_EQ(2U, ports_.size()); | 1804 EXPECT_EQ(2U, ports_.size()); |
| 1758 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1805 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1806 kDefaultAllocationTimeout, fake_clock); |
| 1759 } | 1807 } |
| 1760 | 1808 |
| 1761 // Test that the ports and candidates are updated with new ufrag/pwd/etc. when | 1809 // Test that the ports and candidates are updated with new ufrag/pwd/etc. when |
| 1762 // a pooled session is taken out of the pool. | 1810 // a pooled session is taken out of the pool. |
| 1763 TEST_F(BasicPortAllocatorTest, TestTransportInformationUpdated) { | 1811 TEST_F(BasicPortAllocatorTest, TestTransportInformationUpdated) { |
| 1764 AddInterface(kClientAddr); | 1812 AddInterface(kClientAddr); |
| 1765 int pool_size = 1; | 1813 int pool_size = 1; |
| 1766 allocator_->SetConfiguration(allocator_->stun_servers(), | 1814 allocator_->SetConfiguration(allocator_->stun_servers(), |
| 1767 allocator_->turn_servers(), pool_size, false); | 1815 allocator_->turn_servers(), pool_size, false); |
| 1768 const PortAllocatorSession* peeked_session = allocator_->GetPooledSession(); | 1816 const PortAllocatorSession* peeked_session = allocator_->GetPooledSession(); |
| 1769 ASSERT_NE(nullptr, peeked_session); | 1817 ASSERT_NE(nullptr, peeked_session); |
| 1770 EXPECT_EQ_WAIT(true, peeked_session->CandidatesAllocationDone(), | 1818 EXPECT_EQ_SIMULATED_WAIT(true, peeked_session->CandidatesAllocationDone(), |
| 1771 kDefaultAllocationTimeout); | 1819 kDefaultAllocationTimeout, fake_clock); |
| 1772 // Expect that when TakePooledSession is called, | 1820 // Expect that when TakePooledSession is called, |
| 1773 // UpdateTransportInformationInternal will be called and the | 1821 // UpdateTransportInformationInternal will be called and the |
| 1774 // BasicPortAllocatorSession will update the ufrag/pwd of ports and | 1822 // BasicPortAllocatorSession will update the ufrag/pwd of ports and |
| 1775 // candidates. | 1823 // candidates. |
| 1776 session_ = | 1824 session_ = |
| 1777 allocator_->TakePooledSession(kContentName, 1, kIceUfrag0, kIcePwd0); | 1825 allocator_->TakePooledSession(kContentName, 1, kIceUfrag0, kIcePwd0); |
| 1778 ASSERT_NE(nullptr, session_.get()); | 1826 ASSERT_NE(nullptr, session_.get()); |
| 1779 auto ready_ports = session_->ReadyPorts(); | 1827 auto ready_ports = session_->ReadyPorts(); |
| 1780 auto candidates = session_->ReadyCandidates(); | 1828 auto candidates = session_->ReadyCandidates(); |
| 1781 EXPECT_FALSE(ready_ports.empty()); | 1829 EXPECT_FALSE(ready_ports.empty()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1796 | 1844 |
| 1797 // Test that a new candidate filter takes effect even on already-gathered | 1845 // Test that a new candidate filter takes effect even on already-gathered |
| 1798 // candidates. | 1846 // candidates. |
| 1799 TEST_F(BasicPortAllocatorTest, TestSetCandidateFilterAfterCandidatesGathered) { | 1847 TEST_F(BasicPortAllocatorTest, TestSetCandidateFilterAfterCandidatesGathered) { |
| 1800 AddInterface(kClientAddr); | 1848 AddInterface(kClientAddr); |
| 1801 int pool_size = 1; | 1849 int pool_size = 1; |
| 1802 allocator_->SetConfiguration(allocator_->stun_servers(), | 1850 allocator_->SetConfiguration(allocator_->stun_servers(), |
| 1803 allocator_->turn_servers(), pool_size, false); | 1851 allocator_->turn_servers(), pool_size, false); |
| 1804 const PortAllocatorSession* peeked_session = allocator_->GetPooledSession(); | 1852 const PortAllocatorSession* peeked_session = allocator_->GetPooledSession(); |
| 1805 ASSERT_NE(nullptr, peeked_session); | 1853 ASSERT_NE(nullptr, peeked_session); |
| 1806 EXPECT_EQ_WAIT(true, peeked_session->CandidatesAllocationDone(), | 1854 EXPECT_EQ_SIMULATED_WAIT(true, peeked_session->CandidatesAllocationDone(), |
| 1807 kDefaultAllocationTimeout); | 1855 kDefaultAllocationTimeout, fake_clock); |
| 1808 size_t initial_candidates_size = peeked_session->ReadyCandidates().size(); | 1856 size_t initial_candidates_size = peeked_session->ReadyCandidates().size(); |
| 1809 size_t initial_ports_size = peeked_session->ReadyPorts().size(); | 1857 size_t initial_ports_size = peeked_session->ReadyPorts().size(); |
| 1810 allocator_->set_candidate_filter(CF_RELAY); | 1858 allocator_->set_candidate_filter(CF_RELAY); |
| 1811 // Assume that when TakePooledSession is called, the candidate filter will be | 1859 // Assume that when TakePooledSession is called, the candidate filter will be |
| 1812 // applied to the pooled session. This is tested by PortAllocatorTest. | 1860 // applied to the pooled session. This is tested by PortAllocatorTest. |
| 1813 session_ = | 1861 session_ = |
| 1814 allocator_->TakePooledSession(kContentName, 1, kIceUfrag0, kIcePwd0); | 1862 allocator_->TakePooledSession(kContentName, 1, kIceUfrag0, kIcePwd0); |
| 1815 ASSERT_NE(nullptr, session_.get()); | 1863 ASSERT_NE(nullptr, session_.get()); |
| 1816 auto candidates = session_->ReadyCandidates(); | 1864 auto candidates = session_->ReadyCandidates(); |
| 1817 auto ports = session_->ReadyPorts(); | 1865 auto ports = session_->ReadyPorts(); |
| 1818 // Sanity check that the number of candidates and ports decreased. | 1866 // Sanity check that the number of candidates and ports decreased. |
| 1819 EXPECT_GT(initial_candidates_size, candidates.size()); | 1867 EXPECT_GT(initial_candidates_size, candidates.size()); |
| 1820 EXPECT_GT(initial_ports_size, ports.size()); | 1868 EXPECT_GT(initial_ports_size, ports.size()); |
| 1821 for (const PortInterface* port : ports) { | 1869 for (const PortInterface* port : ports) { |
| 1822 // Expect only relay ports. | 1870 // Expect only relay ports. |
| 1823 EXPECT_EQ(RELAY_PORT_TYPE, port->Type()); | 1871 EXPECT_EQ(RELAY_PORT_TYPE, port->Type()); |
| 1824 } | 1872 } |
| 1825 for (const Candidate& candidate : candidates) { | 1873 for (const Candidate& candidate : candidates) { |
| 1826 // Expect only relay candidates now that the filter is applied. | 1874 // Expect only relay candidates now that the filter is applied. |
| 1827 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); | 1875 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); |
| 1828 // Expect that the raddr is emptied due to the CF_RELAY filter. | 1876 // Expect that the raddr is emptied due to the CF_RELAY filter. |
| 1829 EXPECT_EQ(candidate.related_address(), | 1877 EXPECT_EQ(candidate.related_address(), |
| 1830 rtc::EmptySocketAddressWithFamily(candidate.address().family())); | 1878 rtc::EmptySocketAddressWithFamily(candidate.address().family())); |
| 1831 } | 1879 } |
| 1832 } | 1880 } |
| 1833 | 1881 |
| 1834 } // namespace cricket | 1882 } // namespace cricket |
| OLD | NEW |