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

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

Issue 1987833002: Add a flag to filter out high-cost networks. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 4 years, 7 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/basicportallocator_unittest.cc
diff --git a/webrtc/p2p/client/basicportallocator_unittest.cc b/webrtc/p2p/client/basicportallocator_unittest.cc
index 83d904f181480deca88bc1701af4e7e451e6208c..39d0ef6f6182337d3b2356ac8e694d07a09557c8 100644
--- a/webrtc/p2p/client/basicportallocator_unittest.cc
+++ b/webrtc/p2p/client/basicportallocator_unittest.cc
@@ -477,6 +477,53 @@ TEST_F(BasicPortAllocatorTest, TestIgnoreNetworksAccordingToIgnoreMask) {
EXPECT_EQ(0x12345602U, candidates_[0].address().ip());
}
+// Test that high cost networks are filtered if the flag
+// GATHER_LOW_COST_NETWORK_ONLY is enabled.
+TEST_F(BasicPortAllocatorTest, TestGatherLowCostNetworkOnly) {
+ SocketAddress addr_wifi(IPAddress(0x12345600U), 0);
+ SocketAddress addr_cellular(IPAddress(0x12345601U), 0);
+ SocketAddress addr_unknown1(IPAddress(0x12345602U), 0);
+ SocketAddress addr_unknown2(IPAddress(0x12345603U), 0);
+ // If both Wifi and Cellular interfaces are present, only gather on the Wifi
+ // interface.
+ AddInterface(addr_wifi, "test_wlan0", rtc::ADAPTER_TYPE_WIFI);
+ AddInterface(addr_cellular, "test_cell0", rtc::ADAPTER_TYPE_CELLULAR);
+ allocator().set_flags(cricket::PORTALLOCATOR_DISABLE_STUN |
+ cricket::PORTALLOCATOR_DISABLE_RELAY |
+ cricket::PORTALLOCATOR_DISABLE_TCP |
+ cricket::PORTALLOCATOR_GATHER_LOW_COST_NETWORK_ONLY);
+ EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
+ session_->StartGettingPorts();
+ EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
+ EXPECT_EQ(1U, candidates_.size());
+ EXPECT_TRUE(addr_wifi.EqualIPs(candidates_[0].address()));
+
+ // If both Cellular and Unknown interfaces are present, only gather on the
+ // Unknown interfaces.
pthatcher1 2016/05/17 20:44:28 Unknown => unknown (and Cellular and Wifi here al
honghaiz3 2016/05/18 05:55:03 Done.
+ candidates_.clear();
+ candidate_allocation_done_ = false;
+ RemoveInterface(addr_wifi);
+ AddInterface(addr_unknown1, "test_unknown0", rtc::ADAPTER_TYPE_UNKNOWN);
+ AddInterface(addr_unknown2, "test_unknown1", rtc::ADAPTER_TYPE_UNKNOWN);
+ session_->StartGettingPorts();
+ EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
+ EXPECT_EQ(2U, candidates_.size());
+ EXPECT_TRUE((addr_unknown1.EqualIPs(candidates_[0].address()) &&
+ addr_unknown2.EqualIPs(candidates_[1].address())) ||
+ (addr_unknown1.EqualIPs(candidates_[1].address()) &&
+ addr_unknown2.EqualIPs(candidates_[0].address())));
+
+ // If Wifi, Cellular, Unknown interfaces are all present, only gather on the
+ // Wifi interface.
+ candidates_.clear();
+ candidate_allocation_done_ = false;
+ AddInterface(addr_wifi, "test_wlan0", rtc::ADAPTER_TYPE_WIFI);
+ session_->StartGettingPorts();
+ EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
+ EXPECT_EQ(1U, candidates_.size());
+ EXPECT_TRUE(addr_wifi.EqualIPs(candidates_[0].address()));
+}
+
// Tests that we allocator session not trying to allocate ports for every 250ms.
TEST_F(BasicPortAllocatorTest, TestNoNetworkInterface) {
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
« 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