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