Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/base/net_util.h" | 5 #include "net/base/net_util.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <ostream> | 9 #include <ostream> |
| 10 | 10 |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 870 EXPECT_NE(WIFI_PHY_LAYER_PROTOCOL_NONE, GetWifiPHYLayerProtocol()); | 870 EXPECT_NE(WIFI_PHY_LAYER_PROTOCOL_NONE, GetWifiPHYLayerProtocol()); |
| 871 } | 871 } |
| 872 #elif !defined(OS_ANDROID) | 872 #elif !defined(OS_ANDROID) |
| 873 char name[IF_NAMESIZE]; | 873 char name[IF_NAMESIZE]; |
| 874 EXPECT_TRUE(if_indextoname(it->interface_index, name)); | 874 EXPECT_TRUE(if_indextoname(it->interface_index, name)); |
| 875 EXPECT_STREQ(it->name.c_str(), name); | 875 EXPECT_STREQ(it->name.c_str(), name); |
| 876 #endif | 876 #endif |
| 877 } | 877 } |
| 878 } | 878 } |
| 879 | 879 |
| 880 TEST(NetUtilTest, ConnectionTypeFromInterfaceList) { | |
|
pauljensen
2015/01/15 15:05:10
please move to network_change_notifier_unittest.cc
derekjchow1
2015/01/15 20:32:51
Done.
| |
| 881 NetworkInterfaceList list; | |
| 882 | |
| 883 // Test empty list. | |
| 884 EXPECT_EQ(net::ConnectionTypeFromInterfaceList(list), | |
| 885 NetworkChangeNotifier::CONNECTION_NONE); | |
| 886 | |
| 887 NetworkInterface interface; | |
|
pauljensen
2015/01/15 15:05:10
please move inside the loop
derekjchow1
2015/01/15 20:32:51
Done.
| |
| 888 for (int i = NetworkChangeNotifier::CONNECTION_UNKNOWN; | |
| 889 i < NetworkChangeNotifier::CONNECTION_LAST; i++) { | |
|
pauljensen
2015/01/15 15:05:10
< should be <=
derekjchow1
2015/01/15 20:32:51
Done.
| |
| 890 // Check individual types. | |
| 891 list.clear(); | |
| 892 interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(i); | |
| 893 list.push_back(interface); | |
| 894 EXPECT_EQ(net::ConnectionTypeFromInterfaceList(list), i); | |
| 895 // Check two types. | |
| 896 for (int j = NetworkChangeNotifier::CONNECTION_UNKNOWN; | |
| 897 j < NetworkChangeNotifier::CONNECTION_LAST; j++) { | |
|
pauljensen
2015/01/15 15:05:10
< should be <=
derekjchow1
2015/01/15 20:32:51
Done.
| |
| 898 list.clear(); | |
| 899 interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(i); | |
| 900 list.push_back(interface); | |
| 901 interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(j); | |
| 902 list.push_back(interface); | |
| 903 EXPECT_EQ(net::ConnectionTypeFromInterfaceList(list), | |
| 904 i == j ? i : NetworkChangeNotifier::CONNECTION_UNKNOWN); | |
| 905 } | |
| 906 } | |
| 907 } | |
| 908 | |
| 880 static const char ifname_em1[] = "em1"; | 909 static const char ifname_em1[] = "em1"; |
| 881 #if defined(OS_WIN) | 910 #if defined(OS_WIN) |
| 882 static const char ifname_vm[] = "VMnet"; | 911 static const char ifname_vm[] = "VMnet"; |
| 883 #else | 912 #else |
| 884 static const char ifname_vm[] = "vmnet"; | 913 static const char ifname_vm[] = "vmnet"; |
| 885 #endif // OS_WIN | 914 #endif // OS_WIN |
| 886 | 915 |
| 887 static const unsigned char kIPv6LocalAddr[] = { | 916 static const unsigned char kIPv6LocalAddr[] = { |
| 888 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; | 917 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; |
| 889 | 918 |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1489 TEST_P(NetUtilNonUniqueNameTest, IsHostnameNonUnique) { | 1518 TEST_P(NetUtilNonUniqueNameTest, IsHostnameNonUnique) { |
| 1490 const NonUniqueNameTestData& test_data = GetParam(); | 1519 const NonUniqueNameTestData& test_data = GetParam(); |
| 1491 | 1520 |
| 1492 EXPECT_EQ(test_data.is_unique, IsUnique(test_data.hostname)); | 1521 EXPECT_EQ(test_data.is_unique, IsUnique(test_data.hostname)); |
| 1493 } | 1522 } |
| 1494 | 1523 |
| 1495 INSTANTIATE_TEST_CASE_P(, NetUtilNonUniqueNameTest, | 1524 INSTANTIATE_TEST_CASE_P(, NetUtilNonUniqueNameTest, |
| 1496 testing::ValuesIn(kNonUniqueNameTestData)); | 1525 testing::ValuesIn(kNonUniqueNameTestData)); |
| 1497 | 1526 |
| 1498 } // namespace net | 1527 } // namespace net |
| OLD | NEW |