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

Unified Diff: webrtc/p2p/client/portallocator_unittest.cc

Issue 1274013002: Bug 4865: Enable connectivity when the remote peer is on public internet. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/p2p/client/portallocator_unittest.cc
diff --git a/webrtc/p2p/client/portallocator_unittest.cc b/webrtc/p2p/client/portallocator_unittest.cc
index 7dc25140cccf91a91194af75af8f8b4c18f33993..18bce601aeac4570426cb25c045ba635ae254deb 100644
--- a/webrtc/p2p/client/portallocator_unittest.cc
+++ b/webrtc/p2p/client/portallocator_unittest.cc
@@ -110,9 +110,20 @@ class PortAllocatorTest : public testing::Test, public sigslot::has_slots<> {
void AddInterface(const SocketAddress& addr) {
network_manager_.AddInterface(addr);
}
+ void AddInterfaceAsDefaultRoute(const SocketAddress& addr) {
+ AddInterface(addr);
+ // When a binding comes from the any address, the |addr| will be used as the
+ // srflx address.
+ vss_->SetDefaultRoute(addr.ipaddr());
+ }
bool SetPortRange(int min_port, int max_port) {
return allocator_->SetPortRange(min_port, max_port);
}
+ // No STUN/TURN configuration.
+ void ResetWithNoServers() {
+ allocator_.reset(new cricket::BasicPortAllocator(&network_manager_));
+ allocator_->set_step_delay(cricket::kMinimumStepDelay);
+ }
void ResetWithNatServer(const rtc::SocketAddress& stun_server) {
nat_server_.reset(new rtc::NATServer(
rtc::NAT_OPEN_CONE, vss_.get(), kNatUdpAddr, kNatTcpAddr, vss_.get(),
@@ -234,7 +245,9 @@ class PortAllocatorTest : public testing::Test, public sigslot::has_slots<> {
void CheckDisableAdapterEnumeration() {
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
- session_->set_flags(cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION);
+ session_->set_flags(cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION |
+ cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
+ cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
session_->StartGettingPorts();
EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
@@ -455,7 +468,7 @@ TEST_F(PortAllocatorTest, TestGetAllPortsNoAdapters) {
// Test that we should only get STUN and TURN candidates when adapter
// enumeration is disabled.
-TEST_F(PortAllocatorTest, TestDisableAdapterEnumeration) {
+TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationBehindNat) {
AddInterface(kClientAddr);
// GTURN is not configured here.
ResetWithNatServer(kStunAddr);
@@ -475,6 +488,44 @@ TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationMultipleInterfaces) {
CheckDisableAdapterEnumeration();
}
+// Test that when adapter enumeration is disabled, STUN is the only candidate
+// for endpoints not behind a NAT.
+TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationWithoutNat) {
juberti1 2015/08/06 23:43:21 can we just parameterize CheckDisableAdapterEnumer
+ AddInterfaceAsDefaultRoute(kClientAddr);
+ allocator_->set_flags(allocator().flags() |
+ cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
+ cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION |
juberti1 2015/08/06 23:43:21 since we have no turn servers, why do we need to d
+ cricket::PORTALLOCATOR_DISABLE_RELAY |
+ cricket::PORTALLOCATOR_DISABLE_TCP |
+ cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
+ EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
+ session_->StartGettingPorts();
+ EXPECT_TRUE_WAIT(1U == ports_.size(), kDefaultAllocationTimeout);
+ ASSERT_EQ_WAIT(1U, candidates_.size(), kDefaultAllocationTimeout);
+ EXPECT_PRED5(CheckCandidate, candidates_[0],
+ cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp",
+ kClientAddr);
+ EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
+}
+
+// Test that when adapter enumeration is disabled, for endpoints without
+// STUN/TURN specified, no candidate is generated.
+TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationWithoutNat_NoCandidate) {
juberti1 2015/08/06 23:43:21 see above
+ AddInterfaceAsDefaultRoute(kClientAddr);
+ ResetWithNoServers();
+ allocator_->set_flags(allocator().flags() |
+ cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
+ cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION |
+ cricket::PORTALLOCATOR_DISABLE_RELAY |
+ cricket::PORTALLOCATOR_DISABLE_TCP |
+ cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
+ EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
+ session_->StartGettingPorts();
+ EXPECT_TRUE_WAIT(1U == ports_.size(), kDefaultAllocationTimeout);
+ EXPECT_EQ(candidates_.size(), 0u);
+ EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
+}
+
// Disable for asan, see
// https://code.google.com/p/webrtc/issues/detail?id=4743 for details.
#if !defined(ADDRESS_SANITIZER)
« webrtc/p2p/client/basicportallocator.cc ('K') | « webrtc/p2p/client/basicportallocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698