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

Side by Side Diff: webrtc/base/network_unittest.cc

Issue 1815473002: Add 16-bit network id to the candidate signaling. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Remove the old NETWORK_COST attribute. Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « webrtc/base/network.cc ('k') | webrtc/base/networkmonitor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 EXPECT_TRUE(changed); 292 EXPECT_TRUE(changed);
293 EXPECT_EQ(stats.ipv6_network_count, 0); 293 EXPECT_EQ(stats.ipv6_network_count, 0);
294 EXPECT_EQ(stats.ipv4_network_count, 1); 294 EXPECT_EQ(stats.ipv4_network_count, 1);
295 listenToNetworkInactive(manager); 295 listenToNetworkInactive(manager);
296 list.clear(); 296 list.clear();
297 297
298 manager.GetNetworks(&list); 298 manager.GetNetworks(&list);
299 EXPECT_EQ(1U, list.size()); 299 EXPECT_EQ(1U, list.size());
300 EXPECT_EQ(ipv4_network1.ToString(), list[0]->ToString()); 300 EXPECT_EQ(ipv4_network1.ToString(), list[0]->ToString());
301 Network* net1 = list[0]; 301 Network* net1 = list[0];
302 uint16_t net_id1 = net1->id();
303 EXPECT_EQ(1, net_id1);
302 list.clear(); 304 list.clear();
303 305
304 // Replace ipv4_network1 with ipv4_network2. 306 // Replace ipv4_network1 with ipv4_network2.
305 list.push_back(new Network(ipv4_network2)); 307 list.push_back(new Network(ipv4_network2));
306 stats = MergeNetworkList(manager, list, &changed); 308 stats = MergeNetworkList(manager, list, &changed);
307 EXPECT_TRUE(changed); 309 EXPECT_TRUE(changed);
308 EXPECT_EQ(stats.ipv6_network_count, 0); 310 EXPECT_EQ(stats.ipv6_network_count, 0);
309 EXPECT_EQ(stats.ipv4_network_count, 1); 311 EXPECT_EQ(stats.ipv4_network_count, 1);
310 EXPECT_EQ(1, num_networks_inactive_); 312 EXPECT_EQ(1, num_networks_inactive_);
311 list.clear(); 313 list.clear();
312 num_networks_inactive_ = 0; 314 num_networks_inactive_ = 0;
313 315
314 manager.GetNetworks(&list); 316 manager.GetNetworks(&list);
315 EXPECT_EQ(1U, list.size()); 317 EXPECT_EQ(1U, list.size());
316 EXPECT_EQ(ipv4_network2.ToString(), list[0]->ToString()); 318 EXPECT_EQ(ipv4_network2.ToString(), list[0]->ToString());
317 Network* net2 = list[0]; 319 Network* net2 = list[0];
320 uint16_t net_id2 = net2->id();
321 // Network id will increase.
322 EXPECT_LT(net_id1, net_id2);
318 list.clear(); 323 list.clear();
319 324
320 // Add Network2 back. 325 // Add Network2 back.
321 list.push_back(new Network(ipv4_network1)); 326 list.push_back(new Network(ipv4_network1));
322 list.push_back(new Network(ipv4_network2)); 327 list.push_back(new Network(ipv4_network2));
323 stats = MergeNetworkList(manager, list, &changed); 328 stats = MergeNetworkList(manager, list, &changed);
324 EXPECT_TRUE(changed); 329 EXPECT_TRUE(changed);
325 EXPECT_EQ(stats.ipv6_network_count, 0); 330 EXPECT_EQ(stats.ipv6_network_count, 0);
326 EXPECT_EQ(stats.ipv4_network_count, 2); 331 EXPECT_EQ(stats.ipv4_network_count, 2);
327 EXPECT_EQ(0, num_networks_inactive_); 332 EXPECT_EQ(0, num_networks_inactive_);
328 list.clear(); 333 list.clear();
329 334
330 // Verify that we get previous instances of Network objects. 335 // Verify that we get previous instances of Network objects.
331 manager.GetNetworks(&list); 336 manager.GetNetworks(&list);
332 EXPECT_EQ(2U, list.size()); 337 EXPECT_EQ(2U, list.size());
333 EXPECT_TRUE((net1 == list[0] && net2 == list[1]) || 338 EXPECT_TRUE((net1 == list[0] && net2 == list[1]) ||
334 (net1 == list[1] && net2 == list[0])); 339 (net1 == list[1] && net2 == list[0]));
340 EXPECT_TRUE((net_id1 == list[0]->id() && net_id2 == list[1]->id()) ||
341 (net_id1 == list[1]->id() && net_id2 == list[0]->id()));
335 list.clear(); 342 list.clear();
336 343
337 // Call MergeNetworkList() again and verify that we don't get update 344 // Call MergeNetworkList() again and verify that we don't get update
338 // notification. 345 // notification.
339 list.push_back(new Network(ipv4_network2)); 346 list.push_back(new Network(ipv4_network2));
340 list.push_back(new Network(ipv4_network1)); 347 list.push_back(new Network(ipv4_network1));
341 stats = MergeNetworkList(manager, list, &changed); 348 stats = MergeNetworkList(manager, list, &changed);
342 EXPECT_FALSE(changed); 349 EXPECT_FALSE(changed);
343 EXPECT_EQ(stats.ipv6_network_count, 0); 350 EXPECT_EQ(stats.ipv6_network_count, 0);
344 EXPECT_EQ(stats.ipv4_network_count, 2); 351 EXPECT_EQ(stats.ipv4_network_count, 2);
345 EXPECT_EQ(0, num_networks_inactive_); 352 EXPECT_EQ(0, num_networks_inactive_);
346 list.clear(); 353 list.clear();
347 354
348 // Verify that we get previous instances of Network objects. 355 // Verify that we get previous instances of Network objects.
349 manager.GetNetworks(&list); 356 manager.GetNetworks(&list);
350 EXPECT_EQ(2U, list.size()); 357 EXPECT_EQ(2U, list.size());
351 EXPECT_TRUE((net1 == list[0] && net2 == list[1]) || 358 EXPECT_TRUE((net1 == list[0] && net2 == list[1]) ||
352 (net1 == list[1] && net2 == list[0])); 359 (net1 == list[1] && net2 == list[0]));
360 EXPECT_TRUE((net_id1 == list[0]->id() && net_id2 == list[1]->id()) ||
361 (net_id1 == list[1]->id() && net_id2 == list[0]->id()));
353 list.clear(); 362 list.clear();
354 } 363 }
355 364
356 // Sets up some test IPv6 networks and appends them to list. 365 // Sets up some test IPv6 networks and appends them to list.
357 // Four networks are added - public and link local, for two interfaces. 366 // Four networks are added - public and link local, for two interfaces.
358 void SetupNetworks(NetworkManager::NetworkList* list) { 367 void SetupNetworks(NetworkManager::NetworkList* list) {
359 IPAddress ip; 368 IPAddress ip;
360 IPAddress prefix; 369 IPAddress prefix;
361 EXPECT_TRUE(IPFromString("abcd::1234:5678:abcd:ef12", &ip)); 370 EXPECT_TRUE(IPFromString("abcd::1234:5678:abcd:ef12", &ip));
362 EXPECT_TRUE(IPFromString("abcd::", &prefix)); 371 EXPECT_TRUE(IPFromString("abcd::", &prefix));
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 manager.set_default_local_addresses(GetLoopbackIP(AF_INET), 1003 manager.set_default_local_addresses(GetLoopbackIP(AF_INET),
995 GetLoopbackIP(AF_INET6)); 1004 GetLoopbackIP(AF_INET6));
996 EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET, &ip)); 1005 EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET, &ip));
997 EXPECT_EQ(ip, GetLoopbackIP(AF_INET)); 1006 EXPECT_EQ(ip, GetLoopbackIP(AF_INET));
998 EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET6, &ip)); 1007 EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET6, &ip));
999 EXPECT_EQ(ip, GetLoopbackIP(AF_INET6)); 1008 EXPECT_EQ(ip, GetLoopbackIP(AF_INET6));
1000 manager.StopUpdating(); 1009 manager.StopUpdating();
1001 } 1010 }
1002 1011
1003 } // namespace rtc 1012 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/network.cc ('k') | webrtc/base/networkmonitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698