| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/base/net_util.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 |
| 8 namespace net { |
| 9 |
| 10 class NetworkChangeNotifierTest : public testing::Test { |
| 11 public: |
| 12 NetworkChangeNotifierTest() {} |
| 13 virtual ~NetworkChangeNotifierTest() {} |
| 14 |
| 15 private: |
| 16 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierTest); |
| 17 }; |
| 18 |
| 19 TEST_F(NetworkChangeNotifierTest, InterfacesToConnectionType) { |
| 20 NetworkInterfaceList list; |
| 21 |
| 22 // Test empty list. |
| 23 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), |
| 24 NetworkChangeNotifier::CONNECTION_UNKNOWN); |
| 25 |
| 26 NetworkInterface interface; |
| 27 for (int i = NetworkChangeNotifier::CONNECTION_UNKNOWN; |
| 28 i < NetworkChangeNotifier::CONNECTION_LAST; |
| 29 i++) { |
| 30 // Check individual types. |
| 31 list.clear(); |
| 32 interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(i); |
| 33 list.push_back(interface); |
| 34 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), i); |
| 35 // Check two types. |
| 36 for (int j = NetworkChangeNotifier::CONNECTION_UNKNOWN; |
| 37 j < NetworkChangeNotifier::CONNECTION_LAST; |
| 38 j++) { |
| 39 list.clear(); |
| 40 interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(i); |
| 41 list.push_back(interface); |
| 42 interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(j); |
| 43 list.push_back(interface); |
| 44 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), |
| 45 i == j ? i : NetworkChangeNotifier::CONNECTION_UNKNOWN); |
| 46 } |
| 47 } |
| 48 |
| 49 #if defined(OS_WIN) |
| 50 // Ignore fake teredo interface. |
| 51 list.clear(); |
| 52 interface.type = NetworkChangeNotifier::CONNECTION_4G; |
| 53 interface.friendly_name = "Teredo Tunneling Pseudo-Interface"; |
| 54 list.push_back(interface); |
| 55 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), |
| 56 NetworkChangeNotifier::CONNECTION_UNKNOWN); |
| 57 interface.type = NetworkChangeNotifier::CONNECTION_3G; |
| 58 interface.friendly_name = ""; |
| 59 list.push_back(interface); |
| 60 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), |
| 61 NetworkChangeNotifier::CONNECTION_3G); |
| 62 list.reverse(); |
| 63 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), |
| 64 NetworkChangeNotifier::CONNECTION_3G); |
| 65 #endif |
| 66 } |
| 67 |
| 68 } // namespace net |
| OLD | NEW |