Chromium Code Reviews| Index: net/base/net_util_unittest.cc |
| diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc |
| index cb9ec1ffc4d8f96ccdb38906ca2e1e162e053eb3..67fdf1da32fed303f672d811e8d9dc14e753338a 100644 |
| --- a/net/base/net_util_unittest.cc |
| +++ b/net/base/net_util_unittest.cc |
| @@ -877,6 +877,35 @@ TEST(NetUtilTest, GetNetworkList) { |
| } |
| } |
| +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.
|
| + NetworkInterfaceList list; |
| + |
| + // Test empty list. |
| + EXPECT_EQ(net::ConnectionTypeFromInterfaceList(list), |
| + NetworkChangeNotifier::CONNECTION_NONE); |
| + |
| + NetworkInterface interface; |
|
pauljensen
2015/01/15 15:05:10
please move inside the loop
derekjchow1
2015/01/15 20:32:51
Done.
|
| + for (int i = NetworkChangeNotifier::CONNECTION_UNKNOWN; |
| + i < NetworkChangeNotifier::CONNECTION_LAST; i++) { |
|
pauljensen
2015/01/15 15:05:10
< should be <=
derekjchow1
2015/01/15 20:32:51
Done.
|
| + // Check individual types. |
| + list.clear(); |
| + interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(i); |
| + list.push_back(interface); |
| + EXPECT_EQ(net::ConnectionTypeFromInterfaceList(list), i); |
| + // Check two types. |
| + for (int j = NetworkChangeNotifier::CONNECTION_UNKNOWN; |
| + j < NetworkChangeNotifier::CONNECTION_LAST; j++) { |
|
pauljensen
2015/01/15 15:05:10
< should be <=
derekjchow1
2015/01/15 20:32:51
Done.
|
| + list.clear(); |
| + interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(i); |
| + list.push_back(interface); |
| + interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(j); |
| + list.push_back(interface); |
| + EXPECT_EQ(net::ConnectionTypeFromInterfaceList(list), |
| + i == j ? i : NetworkChangeNotifier::CONNECTION_UNKNOWN); |
| + } |
| + } |
| +} |
| + |
| static const char ifname_em1[] = "em1"; |
| #if defined(OS_WIN) |
| static const char ifname_vm[] = "VMnet"; |