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

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

Issue 1336553003: Revert change which removes GICE (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/p2p/client/fakeportallocator.h ('k') | webrtc/p2p/p2p.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2009 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 uint32 total_ports, 246 uint32 total_ports,
247 const rtc::IPAddress& host_candidate_addr, 247 const rtc::IPAddress& host_candidate_addr,
248 const rtc::IPAddress& stun_candidate_addr, 248 const rtc::IPAddress& stun_candidate_addr,
249 const rtc::IPAddress& relay_candidate_udp_transport_addr, 249 const rtc::IPAddress& relay_candidate_udp_transport_addr,
250 const rtc::IPAddress& relay_candidate_tcp_transport_addr) { 250 const rtc::IPAddress& relay_candidate_tcp_transport_addr) {
251 if (!session_) { 251 if (!session_) {
252 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 252 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
253 } 253 }
254 session_->set_flags(session_->flags() | 254 session_->set_flags(session_->flags() |
255 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION | 255 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION |
256 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
256 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); 257 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
257 allocator().set_allow_tcp_listen(false); 258 allocator().set_allow_tcp_listen(false);
258 session_->StartGettingPorts(); 259 session_->StartGettingPorts();
259 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); 260 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
260 261
261 uint32 total_candidates = 0; 262 uint32 total_candidates = 0;
262 if (!host_candidate_addr.IsNil()) { 263 if (!host_candidate_addr.IsNil()) {
263 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates], 264 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates],
264 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", 265 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp",
265 rtc::SocketAddress(host_candidate_addr, 0)); 266 rtc::SocketAddress(host_candidate_addr, 0));
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 // the relay server. 611 // the relay server.
611 TEST_F(PortAllocatorTest, TestDisableUdpTurn) { 612 TEST_F(PortAllocatorTest, TestDisableUdpTurn) {
612 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); 613 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP);
613 AddInterface(kClientAddr); 614 AddInterface(kClientAddr);
614 ResetWithStunServerAndNat(kStunAddr); 615 ResetWithStunServerAndNat(kStunAddr);
615 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); 616 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr);
616 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 617 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
617 session_->set_flags(cricket::PORTALLOCATOR_DISABLE_UDP_RELAY | 618 session_->set_flags(cricket::PORTALLOCATOR_DISABLE_UDP_RELAY |
618 cricket::PORTALLOCATOR_DISABLE_UDP | 619 cricket::PORTALLOCATOR_DISABLE_UDP |
619 cricket::PORTALLOCATOR_DISABLE_STUN | 620 cricket::PORTALLOCATOR_DISABLE_STUN |
621 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
620 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); 622 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
621 623
622 session_->StartGettingPorts(); 624 session_->StartGettingPorts();
623 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); 625 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
624 626
625 // Expect to see 2 ports and 2 candidates - TURN/TCP and TCP ports, TCP and 627 // Expect to see 2 ports and 2 candidates - TURN/TCP and TCP ports, TCP and
626 // TURN/TCP candidates. 628 // TURN/TCP candidates.
627 EXPECT_EQ(2U, ports_.size()); 629 EXPECT_EQ(2U, ports_.size());
628 EXPECT_EQ(2U, candidates_.size()); 630 EXPECT_EQ(2U, candidates_.size());
629 EXPECT_PRED5(CheckCandidate, candidates_[0], 631 EXPECT_PRED5(CheckCandidate, candidates_[0],
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 for (size_t i = 0; i < candidates_.size(); ++i) { 801 for (size_t i = 0; i < candidates_.size(); ++i) {
800 EXPECT_EQ(std::string(cricket::RELAY_PORT_TYPE), candidates_[i].type()); 802 EXPECT_EQ(std::string(cricket::RELAY_PORT_TYPE), candidates_[i].type());
801 EXPECT_EQ( 803 EXPECT_EQ(
802 candidates_[0].related_address(), 804 candidates_[0].related_address(),
803 rtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); 805 rtc::EmptySocketAddressWithFamily(candidates_[0].address().family()));
804 } 806 }
805 } 807 }
806 808
807 TEST_F(PortAllocatorTest, TestCandidateFilterWithHostOnly) { 809 TEST_F(PortAllocatorTest, TestCandidateFilterWithHostOnly) {
808 AddInterface(kClientAddr); 810 AddInterface(kClientAddr);
809 allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); 811 allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
812 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
810 allocator().set_candidate_filter(cricket::CF_HOST); 813 allocator().set_candidate_filter(cricket::CF_HOST);
811 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 814 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
812 session_->StartGettingPorts(); 815 session_->StartGettingPorts();
813 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); 816 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
814 EXPECT_EQ(2U, candidates_.size()); // Host UDP/TCP candidates only. 817 EXPECT_EQ(2U, candidates_.size()); // Host UDP/TCP candidates only.
815 EXPECT_EQ(2U, ports_.size()); // UDP/TCP ports only. 818 EXPECT_EQ(2U, ports_.size()); // UDP/TCP ports only.
816 for (size_t i = 0; i < candidates_.size(); ++i) { 819 for (size_t i = 0; i < candidates_.size(); ++i) {
817 EXPECT_EQ(std::string(cricket::LOCAL_PORT_TYPE), candidates_[i].type()); 820 EXPECT_EQ(std::string(cricket::LOCAL_PORT_TYPE), candidates_[i].type());
818 } 821 }
819 } 822 }
820 823
821 // Host is behind the NAT. 824 // Host is behind the NAT.
822 TEST_F(PortAllocatorTest, TestCandidateFilterWithReflexiveOnly) { 825 TEST_F(PortAllocatorTest, TestCandidateFilterWithReflexiveOnly) {
823 AddInterface(kPrivateAddr); 826 AddInterface(kPrivateAddr);
824 ResetWithStunServerAndNat(kStunAddr); 827 ResetWithStunServerAndNat(kStunAddr);
825 828
826 allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); 829 allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
830 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
827 allocator().set_candidate_filter(cricket::CF_REFLEXIVE); 831 allocator().set_candidate_filter(cricket::CF_REFLEXIVE);
828 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 832 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
829 session_->StartGettingPorts(); 833 session_->StartGettingPorts();
830 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); 834 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
831 // Host is behind NAT, no private address will be exposed. Hence only UDP 835 // Host is behind NAT, no private address will be exposed. Hence only UDP
832 // port with STUN candidate will be sent outside. 836 // port with STUN candidate will be sent outside.
833 EXPECT_EQ(1U, candidates_.size()); // Only STUN candidate. 837 EXPECT_EQ(1U, candidates_.size()); // Only STUN candidate.
834 EXPECT_EQ(1U, ports_.size()); // Only UDP port will be in ready state. 838 EXPECT_EQ(1U, ports_.size()); // Only UDP port will be in ready state.
835 for (size_t i = 0; i < candidates_.size(); ++i) { 839 for (size_t i = 0; i < candidates_.size(); ++i) {
836 EXPECT_EQ(std::string(cricket::STUN_PORT_TYPE), candidates_[i].type()); 840 EXPECT_EQ(std::string(cricket::STUN_PORT_TYPE), candidates_[i].type());
837 EXPECT_EQ( 841 EXPECT_EQ(
838 candidates_[0].related_address(), 842 candidates_[0].related_address(),
839 rtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); 843 rtc::EmptySocketAddressWithFamily(candidates_[0].address().family()));
840 } 844 }
841 } 845 }
842 846
843 // Host is not behind the NAT. 847 // Host is not behind the NAT.
844 TEST_F(PortAllocatorTest, TestCandidateFilterWithReflexiveOnlyAndNoNAT) { 848 TEST_F(PortAllocatorTest, TestCandidateFilterWithReflexiveOnlyAndNoNAT) {
845 AddInterface(kClientAddr); 849 AddInterface(kClientAddr);
846 allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); 850 allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
851 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
847 allocator().set_candidate_filter(cricket::CF_REFLEXIVE); 852 allocator().set_candidate_filter(cricket::CF_REFLEXIVE);
848 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 853 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
849 session_->StartGettingPorts(); 854 session_->StartGettingPorts();
850 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); 855 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
851 // Host has a public address, both UDP and TCP candidates will be exposed. 856 // Host has a public address, both UDP and TCP candidates will be exposed.
852 EXPECT_EQ(2U, candidates_.size()); // Local UDP + TCP candidate. 857 EXPECT_EQ(2U, candidates_.size()); // Local UDP + TCP candidate.
853 EXPECT_EQ(2U, ports_.size()); // UDP and TCP ports will be in ready state. 858 EXPECT_EQ(2U, ports_.size()); // UDP and TCP ports will be in ready state.
854 for (size_t i = 0; i < candidates_.size(); ++i) { 859 for (size_t i = 0; i < candidates_.size(); ++i) {
855 EXPECT_EQ(std::string(cricket::LOCAL_PORT_TYPE), candidates_[i].type()); 860 EXPECT_EQ(std::string(cricket::LOCAL_PORT_TYPE), candidates_[i].type());
856 } 861 }
857 } 862 }
858 863
859 // Test that we get the same ufrag and pwd for all candidates. 864 // Test that when the PORTALLOCATOR_ENABLE_SHARED_UFRAG is enabled we got same
865 // ufrag and pwd for the collected candidates.
860 TEST_F(PortAllocatorTest, TestEnableSharedUfrag) { 866 TEST_F(PortAllocatorTest, TestEnableSharedUfrag) {
867 allocator().set_flags(allocator().flags() |
868 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG);
861 AddInterface(kClientAddr); 869 AddInterface(kClientAddr);
862 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 870 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
863 session_->StartGettingPorts(); 871 session_->StartGettingPorts();
864 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); 872 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout);
865 EXPECT_PRED5(CheckCandidate, candidates_[0], 873 EXPECT_PRED5(CheckCandidate, candidates_[0],
866 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); 874 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr);
867 EXPECT_PRED5(CheckCandidate, candidates_[1], 875 EXPECT_PRED5(CheckCandidate, candidates_[1],
868 cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", kClientAddr); 876 cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", kClientAddr);
869 EXPECT_PRED5(CheckCandidate, candidates_[5], 877 EXPECT_PRED5(CheckCandidate, candidates_[5],
870 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "tcp", kClientAddr); 878 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "tcp", kClientAddr);
871 EXPECT_EQ(4U, ports_.size()); 879 EXPECT_EQ(4U, ports_.size());
872 EXPECT_EQ(kIceUfrag0, candidates_[0].username()); 880 EXPECT_EQ(kIceUfrag0, candidates_[0].username());
873 EXPECT_EQ(kIceUfrag0, candidates_[1].username()); 881 EXPECT_EQ(kIceUfrag0, candidates_[1].username());
874 EXPECT_EQ(kIceUfrag0, candidates_[2].username()); 882 EXPECT_EQ(kIceUfrag0, candidates_[2].username());
875 EXPECT_EQ(kIcePwd0, candidates_[0].password()); 883 EXPECT_EQ(kIcePwd0, candidates_[0].password());
876 EXPECT_EQ(kIcePwd0, candidates_[1].password()); 884 EXPECT_EQ(kIcePwd0, candidates_[1].password());
877 EXPECT_TRUE(candidate_allocation_done_); 885 EXPECT_TRUE(candidate_allocation_done_);
878 } 886 }
879 887
888 // Test that when the PORTALLOCATOR_ENABLE_SHARED_UFRAG isn't enabled we got
889 // different ufrag and pwd for the collected candidates.
890 TEST_F(PortAllocatorTest, TestDisableSharedUfrag) {
891 allocator().set_flags(allocator().flags() &
892 ~cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG);
893 AddInterface(kClientAddr);
894 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
895 session_->StartGettingPorts();
896 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout);
897 EXPECT_PRED5(CheckCandidate, candidates_[0],
898 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr);
899 EXPECT_PRED5(CheckCandidate, candidates_[1],
900 cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", kClientAddr);
901 EXPECT_EQ(4U, ports_.size());
902 // Port should generate random ufrag and pwd.
903 EXPECT_NE(kIceUfrag0, candidates_[0].username());
904 EXPECT_NE(kIceUfrag0, candidates_[1].username());
905 EXPECT_NE(candidates_[0].username(), candidates_[1].username());
906 EXPECT_NE(kIcePwd0, candidates_[0].password());
907 EXPECT_NE(kIcePwd0, candidates_[1].password());
908 EXPECT_NE(candidates_[0].password(), candidates_[1].password());
909 EXPECT_TRUE(candidate_allocation_done_);
910 }
911
880 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port 912 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port
881 // is allocated for udp and stun. Also verify there is only one candidate 913 // is allocated for udp and stun. Also verify there is only one candidate
882 // (local) if stun candidate is same as local candidate, which will be the case 914 // (local) if stun candidate is same as local candidate, which will be the case
883 // in a public network like the below test. 915 // in a public network like the below test.
884 TEST_F(PortAllocatorTest, TestSharedSocketWithoutNat) { 916 TEST_F(PortAllocatorTest, TestSharedSocketWithoutNat) {
885 AddInterface(kClientAddr); 917 AddInterface(kClientAddr);
886 allocator_->set_flags(allocator().flags() | 918 allocator_->set_flags(allocator().flags() |
919 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
887 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); 920 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
888 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 921 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
889 session_->StartGettingPorts(); 922 session_->StartGettingPorts();
890 ASSERT_EQ_WAIT(6U, candidates_.size(), kDefaultAllocationTimeout); 923 ASSERT_EQ_WAIT(6U, candidates_.size(), kDefaultAllocationTimeout);
891 EXPECT_EQ(3U, ports_.size()); 924 EXPECT_EQ(3U, ports_.size());
892 EXPECT_PRED5(CheckCandidate, candidates_[0], 925 EXPECT_PRED5(CheckCandidate, candidates_[0],
893 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); 926 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr);
894 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); 927 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
895 } 928 }
896 929
897 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port 930 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port
898 // is allocated for udp and stun. In this test we should expect both stun and 931 // is allocated for udp and stun. In this test we should expect both stun and
899 // local candidates as client behind a nat. 932 // local candidates as client behind a nat.
900 TEST_F(PortAllocatorTest, TestSharedSocketWithNat) { 933 TEST_F(PortAllocatorTest, TestSharedSocketWithNat) {
901 AddInterface(kClientAddr); 934 AddInterface(kClientAddr);
902 ResetWithStunServerAndNat(kStunAddr); 935 ResetWithStunServerAndNat(kStunAddr);
903 936
904 allocator_->set_flags(allocator().flags() | 937 allocator_->set_flags(allocator().flags() |
938 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
905 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); 939 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
906 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 940 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
907 session_->StartGettingPorts(); 941 session_->StartGettingPorts();
908 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); 942 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout);
909 ASSERT_EQ(2U, ports_.size()); 943 ASSERT_EQ(2U, ports_.size());
910 EXPECT_PRED5(CheckCandidate, candidates_[0], 944 EXPECT_PRED5(CheckCandidate, candidates_[0],
911 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); 945 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr);
912 EXPECT_PRED5(CheckCandidate, candidates_[1], 946 EXPECT_PRED5(CheckCandidate, candidates_[1],
913 cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", 947 cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp",
914 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); 948 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0));
915 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); 949 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
916 EXPECT_EQ(3U, candidates_.size()); 950 EXPECT_EQ(3U, candidates_.size());
917 } 951 }
918 952
919 // Test TURN port in shared socket mode with UDP and TCP TURN server addresses. 953 // Test TURN port in shared socket mode with UDP and TCP TURN server addresses.
920 TEST_F(PortAllocatorTest, TestSharedSocketWithoutNatUsingTurn) { 954 TEST_F(PortAllocatorTest, TestSharedSocketWithoutNatUsingTurn) {
921 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); 955 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP);
922 AddInterface(kClientAddr); 956 AddInterface(kClientAddr);
923 allocator_.reset(new cricket::BasicPortAllocator(&network_manager_)); 957 allocator_.reset(new cricket::BasicPortAllocator(&network_manager_));
924 958
925 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); 959 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr);
926 960
927 allocator_->set_step_delay(cricket::kMinimumStepDelay); 961 allocator_->set_step_delay(cricket::kMinimumStepDelay);
928 allocator_->set_flags(allocator().flags() | 962 allocator_->set_flags(allocator().flags() |
963 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
929 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | 964 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET |
930 cricket::PORTALLOCATOR_DISABLE_TCP); 965 cricket::PORTALLOCATOR_DISABLE_TCP);
931 966
932 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 967 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
933 session_->StartGettingPorts(); 968 session_->StartGettingPorts();
934 969
935 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); 970 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout);
936 ASSERT_EQ(3U, ports_.size()); 971 ASSERT_EQ(3U, ports_.size());
937 EXPECT_PRED5(CheckCandidate, candidates_[0], 972 EXPECT_PRED5(CheckCandidate, candidates_[0],
938 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); 973 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr);
(...skipping 17 matching lines...) Expand all
956 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); 991 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN);
957 cricket::RelayCredentials credentials(kTurnUsername, kTurnPassword); 992 cricket::RelayCredentials credentials(kTurnUsername, kTurnPassword);
958 relay_server.credentials = credentials; 993 relay_server.credentials = credentials;
959 relay_server.ports.push_back(cricket::ProtocolAddress( 994 relay_server.ports.push_back(cricket::ProtocolAddress(
960 rtc::SocketAddress("localhost", 3478), 995 rtc::SocketAddress("localhost", 3478),
961 cricket::PROTO_UDP, false)); 996 cricket::PROTO_UDP, false));
962 allocator_->AddRelay(relay_server); 997 allocator_->AddRelay(relay_server);
963 998
964 allocator_->set_step_delay(cricket::kMinimumStepDelay); 999 allocator_->set_step_delay(cricket::kMinimumStepDelay);
965 allocator_->set_flags(allocator().flags() | 1000 allocator_->set_flags(allocator().flags() |
1001 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
966 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | 1002 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET |
967 cricket::PORTALLOCATOR_DISABLE_TCP); 1003 cricket::PORTALLOCATOR_DISABLE_TCP);
968 1004
969 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 1005 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
970 session_->StartGettingPorts(); 1006 session_->StartGettingPorts();
971 1007
972 EXPECT_EQ_WAIT(2U, ports_.size(), kDefaultAllocationTimeout); 1008 EXPECT_EQ_WAIT(2U, ports_.size(), kDefaultAllocationTimeout);
973 } 1009 }
974 1010
975 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port 1011 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port
976 // is allocated for udp/stun/turn. In this test we should expect all local, 1012 // is allocated for udp/stun/turn. In this test we should expect all local,
977 // stun and turn candidates. 1013 // stun and turn candidates.
978 TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurn) { 1014 TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurn) {
979 AddInterface(kClientAddr); 1015 AddInterface(kClientAddr);
980 ResetWithStunServerAndNat(kStunAddr); 1016 ResetWithStunServerAndNat(kStunAddr);
981 1017
982 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); 1018 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress());
983 1019
984 allocator_->set_flags(allocator().flags() | 1020 allocator_->set_flags(allocator().flags() |
1021 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
985 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | 1022 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET |
986 cricket::PORTALLOCATOR_DISABLE_TCP); 1023 cricket::PORTALLOCATOR_DISABLE_TCP);
987 1024
988 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 1025 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
989 session_->StartGettingPorts(); 1026 session_->StartGettingPorts();
990 1027
991 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); 1028 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout);
992 ASSERT_EQ(2U, ports_.size()); 1029 ASSERT_EQ(2U, ports_.size());
993 EXPECT_PRED5(CheckCandidate, candidates_[0], 1030 EXPECT_PRED5(CheckCandidate, candidates_[0],
994 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); 1031 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr);
(...skipping 18 matching lines...) Expand all
1013 // Use an empty SocketAddress to add a NAT without STUN server. 1050 // Use an empty SocketAddress to add a NAT without STUN server.
1014 ResetWithStunServerAndNat(SocketAddress()); 1051 ResetWithStunServerAndNat(SocketAddress());
1015 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); 1052 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress());
1016 1053
1017 // Must set the step delay to 0 to make sure the relay allocation phase is 1054 // Must set the step delay to 0 to make sure the relay allocation phase is
1018 // started before the STUN candidates are obtained, so that the STUN binding 1055 // started before the STUN candidates are obtained, so that the STUN binding
1019 // response is processed when both StunPort and TurnPort exist to reproduce 1056 // response is processed when both StunPort and TurnPort exist to reproduce
1020 // webrtc issue 3537. 1057 // webrtc issue 3537.
1021 allocator_->set_step_delay(0); 1058 allocator_->set_step_delay(0);
1022 allocator_->set_flags(allocator().flags() | 1059 allocator_->set_flags(allocator().flags() |
1060 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
1023 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | 1061 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET |
1024 cricket::PORTALLOCATOR_DISABLE_TCP); 1062 cricket::PORTALLOCATOR_DISABLE_TCP);
1025 1063
1026 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 1064 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
1027 session_->StartGettingPorts(); 1065 session_->StartGettingPorts();
1028 1066
1029 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); 1067 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout);
1030 EXPECT_PRED5(CheckCandidate, candidates_[0], 1068 EXPECT_PRED5(CheckCandidate, candidates_[0],
1031 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); 1069 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr);
1032 EXPECT_PRED5(CheckCandidate, candidates_[1], 1070 EXPECT_PRED5(CheckCandidate, candidates_[1],
(...skipping 14 matching lines...) Expand all
1047 // Test that when only a TCP TURN server is available, we do NOT use it as 1085 // Test that when only a TCP TURN server is available, we do NOT use it as
1048 // a UDP STUN server, as this could leak our IP address. Thus we should only 1086 // a UDP STUN server, as this could leak our IP address. Thus we should only
1049 // expect two ports, a UDPPort and TurnPort. 1087 // expect two ports, a UDPPort and TurnPort.
1050 TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnTcpOnly) { 1088 TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnTcpOnly) {
1051 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); 1089 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP);
1052 AddInterface(kClientAddr); 1090 AddInterface(kClientAddr);
1053 ResetWithStunServerAndNat(rtc::SocketAddress()); 1091 ResetWithStunServerAndNat(rtc::SocketAddress());
1054 AddTurnServers(rtc::SocketAddress(), kTurnTcpIntAddr); 1092 AddTurnServers(rtc::SocketAddress(), kTurnTcpIntAddr);
1055 1093
1056 allocator_->set_flags(allocator().flags() | 1094 allocator_->set_flags(allocator().flags() |
1095 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
1057 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | 1096 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET |
1058 cricket::PORTALLOCATOR_DISABLE_TCP); 1097 cricket::PORTALLOCATOR_DISABLE_TCP);
1059 1098
1060 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 1099 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
1061 session_->StartGettingPorts(); 1100 session_->StartGettingPorts();
1062 1101
1063 ASSERT_EQ_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout); 1102 ASSERT_EQ_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout);
1064 ASSERT_EQ(2U, ports_.size()); 1103 ASSERT_EQ(2U, ports_.size());
1065 EXPECT_PRED5(CheckCandidate, candidates_[0], 1104 EXPECT_PRED5(CheckCandidate, candidates_[0],
1066 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", 1105 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp",
(...skipping 12 matching lines...) Expand all
1079 // 'relay' candidates. 1118 // 'relay' candidates.
1080 // TODO(deadbeef): Remove this test when support for non-shared socket mode 1119 // TODO(deadbeef): Remove this test when support for non-shared socket mode
1081 // is removed. 1120 // is removed.
1082 TEST_F(PortAllocatorTest, TestNonSharedSocketWithNatUsingTurnAsStun) { 1121 TEST_F(PortAllocatorTest, TestNonSharedSocketWithNatUsingTurnAsStun) {
1083 AddInterface(kClientAddr); 1122 AddInterface(kClientAddr);
1084 // Use an empty SocketAddress to add a NAT without STUN server. 1123 // Use an empty SocketAddress to add a NAT without STUN server.
1085 ResetWithStunServerAndNat(SocketAddress()); 1124 ResetWithStunServerAndNat(SocketAddress());
1086 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); 1125 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress());
1087 1126
1088 allocator_->set_flags(allocator().flags() | 1127 allocator_->set_flags(allocator().flags() |
1128 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
1089 cricket::PORTALLOCATOR_DISABLE_TCP); 1129 cricket::PORTALLOCATOR_DISABLE_TCP);
1090 1130
1091 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 1131 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
1092 session_->StartGettingPorts(); 1132 session_->StartGettingPorts();
1093 1133
1094 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); 1134 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout);
1095 ASSERT_EQ(3U, ports_.size()); 1135 ASSERT_EQ(3U, ports_.size());
1096 EXPECT_PRED5(CheckCandidate, candidates_[0], 1136 EXPECT_PRED5(CheckCandidate, candidates_[0],
1097 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", 1137 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp",
1098 kClientAddr); 1138 kClientAddr);
(...skipping 18 matching lines...) Expand all
1117 // server is used as a STUN server and we get a 'stun' candidate. 1157 // server is used as a STUN server and we get a 'stun' candidate.
1118 TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnAndStun) { 1158 TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnAndStun) {
1119 AddInterface(kClientAddr); 1159 AddInterface(kClientAddr);
1120 // Configure with STUN server but destroy it, so we can ensure that it's 1160 // Configure with STUN server but destroy it, so we can ensure that it's
1121 // the TURN server actually being used as a STUN server. 1161 // the TURN server actually being used as a STUN server.
1122 ResetWithStunServerAndNat(kStunAddr); 1162 ResetWithStunServerAndNat(kStunAddr);
1123 stun_server_.reset(); 1163 stun_server_.reset();
1124 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); 1164 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress());
1125 1165
1126 allocator_->set_flags(allocator().flags() | 1166 allocator_->set_flags(allocator().flags() |
1167 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
1127 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | 1168 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET |
1128 cricket::PORTALLOCATOR_DISABLE_TCP); 1169 cricket::PORTALLOCATOR_DISABLE_TCP);
1129 1170
1130 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 1171 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
1131 session_->StartGettingPorts(); 1172 session_->StartGettingPorts();
1132 1173
1133 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); 1174 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout);
1134 EXPECT_PRED5(CheckCandidate, candidates_[0], 1175 EXPECT_PRED5(CheckCandidate, candidates_[0],
1135 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", 1176 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp",
1136 kClientAddr); 1177 kClientAddr);
1137 EXPECT_PRED5(CheckCandidate, candidates_[1], 1178 EXPECT_PRED5(CheckCandidate, candidates_[1],
1138 cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", 1179 cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp",
1139 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); 1180 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0));
1140 EXPECT_PRED5(CheckCandidate, candidates_[2], 1181 EXPECT_PRED5(CheckCandidate, candidates_[2],
1141 cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp", 1182 cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp",
1142 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); 1183 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
1143 EXPECT_EQ(candidates_[2].related_address(), candidates_[1].address()); 1184 EXPECT_EQ(candidates_[2].related_address(), candidates_[1].address());
1144 1185
1145 // Don't bother waiting for STUN timeout, since we already verified 1186 // Don't bother waiting for STUN timeout, since we already verified
1146 // that we got a STUN candidate from the TURN server. 1187 // that we got a STUN candidate from the TURN server.
1147 } 1188 }
1148 1189
1149 // This test verifies when PORTALLOCATOR_ENABLE_SHARED_SOCKET flag is enabled 1190 // This test verifies when PORTALLOCATOR_ENABLE_SHARED_SOCKET flag is enabled
1150 // and fail to generate STUN candidate, local UDP candidate is generated 1191 // and fail to generate STUN candidate, local UDP candidate is generated
1151 // properly. 1192 // properly.
1152 TEST_F(PortAllocatorTest, TestSharedSocketNoUdpAllowed) { 1193 TEST_F(PortAllocatorTest, TestSharedSocketNoUdpAllowed) {
1153 allocator().set_flags(allocator().flags() | 1194 allocator().set_flags(allocator().flags() |
1154 cricket::PORTALLOCATOR_DISABLE_RELAY | 1195 cricket::PORTALLOCATOR_DISABLE_RELAY |
1155 cricket::PORTALLOCATOR_DISABLE_TCP | 1196 cricket::PORTALLOCATOR_DISABLE_TCP |
1197 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
1156 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); 1198 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
1157 fss_->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, kClientAddr); 1199 fss_->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, kClientAddr);
1158 AddInterface(kClientAddr); 1200 AddInterface(kClientAddr);
1159 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 1201 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
1160 session_->StartGettingPorts(); 1202 session_->StartGettingPorts();
1161 ASSERT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout); 1203 ASSERT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout);
1162 EXPECT_EQ(1U, candidates_.size()); 1204 EXPECT_EQ(1U, candidates_.size());
1163 EXPECT_PRED5(CheckCandidate, candidates_[0], 1205 EXPECT_PRED5(CheckCandidate, candidates_[0],
1164 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); 1206 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr);
1165 // STUN timeout is 9sec. We need to wait to get candidate done signal. 1207 // STUN timeout is 9sec. We need to wait to get candidate done signal.
1166 EXPECT_TRUE_WAIT(candidate_allocation_done_, 10000); 1208 EXPECT_TRUE_WAIT(candidate_allocation_done_, 10000);
1167 EXPECT_EQ(1U, candidates_.size()); 1209 EXPECT_EQ(1U, candidates_.size());
1168 } 1210 }
1169 1211
1170 // Test that when the NetworkManager doesn't have permission to enumerate 1212 // Test that when the NetworkManager doesn't have permission to enumerate
1171 // adapters, the PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified 1213 // adapters, the PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified
1172 // automatically. 1214 // automatically.
1173 TEST_F(PortAllocatorTest, TestNetworkPermissionBlocked) { 1215 TEST_F(PortAllocatorTest, TestNetworkPermissionBlocked) {
1174 AddInterface(kClientAddr); 1216 AddInterface(kClientAddr);
1175 network_manager_.set_enumeration_permission( 1217 network_manager_.set_enumeration_permission(
1176 rtc::NetworkManager::ENUMERATION_BLOCKED); 1218 rtc::NetworkManager::ENUMERATION_BLOCKED);
1177 allocator().set_flags(allocator().flags() | 1219 allocator().set_flags(allocator().flags() |
1178 cricket::PORTALLOCATOR_DISABLE_RELAY | 1220 cricket::PORTALLOCATOR_DISABLE_RELAY |
1179 cricket::PORTALLOCATOR_DISABLE_TCP | 1221 cricket::PORTALLOCATOR_DISABLE_TCP |
1222 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
1180 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); 1223 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
1181 EXPECT_EQ(0U, allocator_->flags() & 1224 EXPECT_EQ(0U, allocator_->flags() &
1182 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); 1225 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION);
1183 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 1226 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
1184 EXPECT_EQ(0U, session_->flags() & 1227 EXPECT_EQ(0U, session_->flags() &
1185 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); 1228 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION);
1186 session_->StartGettingPorts(); 1229 session_->StartGettingPorts();
1187 EXPECT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout); 1230 EXPECT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout);
1188 EXPECT_EQ(0U, candidates_.size()); 1231 EXPECT_EQ(0U, candidates_.size());
1189 EXPECT_TRUE((session_->flags() & 1232 EXPECT_TRUE((session_->flags() &
1190 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) != 0); 1233 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) != 0);
1191 } 1234 }
1192 1235
1193 // This test verifies allocator can use IPv6 addresses along with IPv4. 1236 // This test verifies allocator can use IPv6 addresses along with IPv4.
1194 TEST_F(PortAllocatorTest, TestEnableIPv6Addresses) { 1237 TEST_F(PortAllocatorTest, TestEnableIPv6Addresses) {
1195 allocator().set_flags(allocator().flags() | 1238 allocator().set_flags(allocator().flags() |
1196 cricket::PORTALLOCATOR_DISABLE_RELAY | 1239 cricket::PORTALLOCATOR_DISABLE_RELAY |
1197 cricket::PORTALLOCATOR_ENABLE_IPV6 | 1240 cricket::PORTALLOCATOR_ENABLE_IPV6 |
1241 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
1198 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); 1242 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
1199 AddInterface(kClientIPv6Addr); 1243 AddInterface(kClientIPv6Addr);
1200 AddInterface(kClientAddr); 1244 AddInterface(kClientAddr);
1201 allocator_->set_step_delay(cricket::kMinimumStepDelay); 1245 allocator_->set_step_delay(cricket::kMinimumStepDelay);
1202 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 1246 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
1203 session_->StartGettingPorts(); 1247 session_->StartGettingPorts();
1204 ASSERT_EQ_WAIT(4U, ports_.size(), kDefaultAllocationTimeout); 1248 ASSERT_EQ_WAIT(4U, ports_.size(), kDefaultAllocationTimeout);
1205 EXPECT_EQ(4U, candidates_.size()); 1249 EXPECT_EQ(4U, candidates_.size());
1206 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); 1250 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
1207 EXPECT_PRED5(CheckCandidate, candidates_[0], 1251 EXPECT_PRED5(CheckCandidate, candidates_[0],
1208 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", 1252 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp",
1209 kClientIPv6Addr); 1253 kClientIPv6Addr);
1210 EXPECT_PRED5(CheckCandidate, candidates_[1], 1254 EXPECT_PRED5(CheckCandidate, candidates_[1],
1211 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", 1255 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp",
1212 kClientAddr); 1256 kClientAddr);
1213 EXPECT_PRED5(CheckCandidate, candidates_[2], 1257 EXPECT_PRED5(CheckCandidate, candidates_[2],
1214 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "tcp", 1258 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "tcp",
1215 kClientIPv6Addr); 1259 kClientIPv6Addr);
1216 EXPECT_PRED5(CheckCandidate, candidates_[3], 1260 EXPECT_PRED5(CheckCandidate, candidates_[3],
1217 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "tcp", 1261 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "tcp",
1218 kClientAddr); 1262 kClientAddr);
1219 EXPECT_EQ(4U, candidates_.size()); 1263 EXPECT_EQ(4U, candidates_.size());
1220 } 1264 }
OLDNEW
« no previous file with comments | « webrtc/p2p/client/fakeportallocator.h ('k') | webrtc/p2p/p2p.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698