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

Unified Diff: webrtc/p2p/base/p2ptransportchannel_unittest.cc

Issue 1668073002: Add network cost as part of the connection comparison. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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/base/p2ptransportchannel_unittest.cc
diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
index 90ddd43714daa8c55bdaa45139caf5f2b7812dbf..cca189d49b34fb86df9d8bc707451d0ee7ca572d 100644
--- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc
+++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
@@ -368,6 +368,13 @@ class P2PTransportChannelTestBase : public testing::Test,
void AddAddress(int endpoint, const SocketAddress& addr) {
GetEndpoint(endpoint)->network_manager_.AddInterface(addr);
}
+ void AddAddress(int endpoint,
+ const SocketAddress& addr,
+ const std::string& ifname,
+ rtc::AdapterType adapter_type) {
+ GetEndpoint(endpoint)->network_manager_.AddInterface(addr, ifname,
+ adapter_type);
+ }
void RemoveAddress(int endpoint, const SocketAddress& addr) {
GetEndpoint(endpoint)->network_manager_.RemoveInterface(addr);
}
@@ -1650,6 +1657,37 @@ TEST_F(P2PTransportChannelMultihomedTest, TestFailoverControllingSide) {
DestroyChannels();
}
+TEST_F(P2PTransportChannelMultihomedTest, TestPreferWifiOverCellularNetwork) {
+ // The interface names are chosen so that |kPublicAddrs| would have higher
+ // candidate priority if it is not for the network type.
+ AddAddress(0, kAlternateAddrs[0], "test0", rtc::ADAPTER_TYPE_WIFI);
+ AddAddress(0, kPublicAddrs[0], "test1", rtc::ADAPTER_TYPE_CELLULAR);
+ AddAddress(1, kAlternateAddrs[1], "test0", rtc::ADAPTER_TYPE_WIFI);
+ AddAddress(1, kPublicAddrs[1], "test1", rtc::ADAPTER_TYPE_CELLULAR);
+
+ // Use only local ports for simplicity.
+ SetAllocatorFlags(0, kOnlyLocalPorts);
+ SetAllocatorFlags(1, kOnlyLocalPorts);
+
+ // Create channels and let them go writable, as usual.
+ CreateChannels(1);
+
+ EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() &&
+ ep2_ch1()->receiving() && ep2_ch1()->writable(),
+ 1000, 1000);
+ // Need to wait to make sure the connections on both networks are writable.
+ EXPECT_TRUE_WAIT(
+ ep1_ch1()->best_connection() &&
+ LocalCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[0]) &&
+ RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1]),
+ 1000);
+ EXPECT_TRUE_WAIT(
+ ep2_ch1()->best_connection() &&
+ LocalCandidate(ep2_ch1())->address().EqualIPs(kAlternateAddrs[1]) &&
+ RemoteCandidate(ep2_ch1())->address().EqualIPs(kAlternateAddrs[0]),
+ 1000);
pthatcher1 2016/02/12 00:07:12 This would be more readable if you did something l
honghaiz3 2016/02/12 19:28:43 Done. We really just need wifi and cellular.
+}
pthatcher1 2016/02/12 00:07:12 Should we have a test case that WiFi -> Cell is pr
honghaiz3 2016/02/12 19:28:43 I think the above test has covered Wifi-Wifi is pr
+
// Test that the backup connection is pinged at a rate no faster than
// what was configured.
TEST_F(P2PTransportChannelMultihomedTest, TestPingBackupConnectionRate) {

Powered by Google App Engine
This is Rietveld 408576698