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

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: merge with head 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
« no previous file with comments | « webrtc/p2p/client/basicportallocator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/client/basicportallocator_unittest.cc
diff --git a/webrtc/p2p/client/basicportallocator_unittest.cc b/webrtc/p2p/client/basicportallocator_unittest.cc
index 0eaa49e4d8db8eba3754515546b75172baeb82ea..6d5d1086a9322e26ff9b1cf6d134f4862ce05507 100644
--- a/webrtc/p2p/client/basicportallocator_unittest.cc
+++ b/webrtc/p2p/client/basicportallocator_unittest.cc
@@ -519,6 +519,53 @@ TEST_F(BasicPortAllocatorTest, TestIgnoreNetworksAccordingToIgnoreMask) {
EXPECT_EQ(0x12345602U, candidates_[0].address().ip());
}
+// Test that high cost networks are filtered if the flag
+// PORTALLOCATOR_DISABLE_COSTLY_NETWORKS is set.
+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 Wi-Fi and cellular interfaces are present, only gather on the Wi-Fi
+ // 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_DISABLE_COSTLY_NETWORKS);
+ 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.
+ 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 Wi-Fi, cellular, unknown interfaces are all present, only gather on the
+ // Wi-Fi 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(ICE_CANDIDATE_COMPONENT_RTP));
« no previous file with comments | « webrtc/p2p/client/basicportallocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698