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

Unified Diff: webrtc/base/network_unittest.cc

Issue 1837823005: GetDefaultLocalAddress should return the bestIP (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Rebase to the master Created 4 years, 8 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/base/network.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/network_unittest.cc
diff --git a/webrtc/base/network_unittest.cc b/webrtc/base/network_unittest.cc
index 7133d8b405df4327db94613ed48fcb9e27e42451..d365477a07e66f31cbafe595d933cbc946b3a2d9 100644
--- a/webrtc/base/network_unittest.cc
+++ b/webrtc/base/network_unittest.cc
@@ -1006,6 +1006,35 @@ TEST_F(NetworkTest, DefaultLocalAddress) {
EXPECT_EQ(ip, GetLoopbackIP(AF_INET));
EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET6, &ip));
EXPECT_EQ(ip, GetLoopbackIP(AF_INET6));
+
+ // More tests on GetDefaultLocalAddress with ipv6 addresses where the set
+ // default address may be different from the best IP address of any network.
+ InterfaceAddress ip1;
+ EXPECT_TRUE(IPFromString("abcd::1234:5678:abcd:1111",
+ IPV6_ADDRESS_FLAG_TEMPORARY, &ip1));
+ // Create a network with a prefix of ip1.
+ Network ipv6_network("test_eth0", "Test NetworkAdapter", TruncateIP(ip1, 64),
+ 64);
+ IPAddress ip2;
+ EXPECT_TRUE(IPFromString("abcd::1234:5678:abcd:2222", &ip2));
+ ipv6_network.AddIP(ip1);
+ ipv6_network.AddIP(ip2);
+ BasicNetworkManager::NetworkList list(1, new Network(ipv6_network));
+ bool changed;
+ MergeNetworkList(manager, list, &changed);
+ // If the set default address is not in any network, GetDefaultLocalAddress
+ // should return it.
+ IPAddress ip3;
+ EXPECT_TRUE(IPFromString("abcd::1234:5678:abcd:3333", &ip3));
+ manager.set_default_local_addresses(GetLoopbackIP(AF_INET), ip3);
+ EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET6, &ip));
+ EXPECT_EQ(ip3, ip);
+ // If the set default address is in a network, GetDefaultLocalAddress will
+ // return the best IP in that network.
+ manager.set_default_local_addresses(GetLoopbackIP(AF_INET), ip2);
+ EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET6, &ip));
+ EXPECT_EQ(static_cast<IPAddress>(ip1), ip);
+
manager.StopUpdating();
}
« no previous file with comments | « webrtc/base/network.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698