| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 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 | 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/network_change_notifier.h" | 5 #include "net/base/network_change_notifier.h" |
| 6 | 6 |
| 7 #include "net/base/network_interfaces.h" | 7 #include "net/base/network_interfaces.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 #if defined(OS_WIN) | 99 #if defined(OS_WIN) |
| 100 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_NONE, | 100 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_NONE, |
| 101 NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list)); | 101 NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list)); |
| 102 #else | 102 #else |
| 103 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_ETHERNET, | 103 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_ETHERNET, |
| 104 NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list)); | 104 NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list)); |
| 105 #endif | 105 #endif |
| 106 } | 106 } |
| 107 | 107 |
| 108 TEST(NetworkChangeNotifierTest, IgnoreAirdropOnMac) { |
| 109 NetworkInterfaceList list; |
| 110 NetworkInterface interface_airdrop; |
| 111 interface_airdrop.type = NetworkChangeNotifier::CONNECTION_ETHERNET; |
| 112 interface_airdrop.name = "awdl0"; |
| 113 interface_airdrop.friendly_name = "awdl0"; |
| 114 list.push_back(interface_airdrop); |
| 115 |
| 116 #if defined(OS_MACOSX) |
| 117 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_NONE, |
| 118 NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list)); |
| 119 #else |
| 120 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_ETHERNET, |
| 121 NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list)); |
| 122 #endif |
| 123 } |
| 124 |
| 125 TEST(NetworkChangeNotifierTest, IgnoreTunnelsOnMac) { |
| 126 NetworkInterfaceList list; |
| 127 NetworkInterface interface_tunnel; |
| 128 interface_tunnel.type = NetworkChangeNotifier::CONNECTION_ETHERNET; |
| 129 interface_tunnel.name = "utun0"; |
| 130 interface_tunnel.friendly_name = "utun0"; |
| 131 list.push_back(interface_tunnel); |
| 132 |
| 133 #if defined(OS_MACOSX) |
| 134 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_NONE, |
| 135 NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list)); |
| 136 #else |
| 137 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_ETHERNET, |
| 138 NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list)); |
| 139 #endif |
| 140 } |
| 141 |
| 108 TEST(NetworkChangeNotifierTest, IgnoreVMInterfaces) { | 142 TEST(NetworkChangeNotifierTest, IgnoreVMInterfaces) { |
| 109 NetworkInterfaceList list; | 143 NetworkInterfaceList list; |
| 110 NetworkInterface interface_vmnet_linux; | 144 NetworkInterface interface_vmnet_linux; |
| 111 interface_vmnet_linux.type = NetworkChangeNotifier::CONNECTION_ETHERNET; | 145 interface_vmnet_linux.type = NetworkChangeNotifier::CONNECTION_ETHERNET; |
| 112 interface_vmnet_linux.name = "vmnet1"; | 146 interface_vmnet_linux.name = "vmnet1"; |
| 113 interface_vmnet_linux.friendly_name = "vmnet1"; | 147 interface_vmnet_linux.friendly_name = "vmnet1"; |
| 114 list.push_back(interface_vmnet_linux); | 148 list.push_back(interface_vmnet_linux); |
| 115 | 149 |
| 116 NetworkInterface interface_vmnet_win; | 150 NetworkInterface interface_vmnet_win; |
| 117 interface_vmnet_win.type = NetworkChangeNotifier::CONNECTION_ETHERNET; | 151 interface_vmnet_win.type = NetworkChangeNotifier::CONNECTION_ETHERNET; |
| 118 interface_vmnet_win.name = "virtualdevice"; | 152 interface_vmnet_win.name = "virtualdevice"; |
| 119 interface_vmnet_win.friendly_name = "VMware Network Adapter VMnet1"; | 153 interface_vmnet_win.friendly_name = "VMware Network Adapter VMnet1"; |
| 120 list.push_back(interface_vmnet_win); | 154 list.push_back(interface_vmnet_win); |
| 121 | 155 |
| 122 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_NONE, | 156 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_NONE, |
| 123 NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list)); | 157 NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list)); |
| 124 } | 158 } |
| 125 | 159 |
| 126 TEST(NetworkChangeNotifierTest, GetConnectionSubtype) { | 160 TEST(NetworkChangeNotifierTest, GetConnectionSubtype) { |
| 127 // Call GetConnectionSubtype() and ensure that there is no crash. | 161 // Call GetConnectionSubtype() and ensure that there is no crash. |
| 128 NetworkChangeNotifier::GetConnectionSubtype(); | 162 NetworkChangeNotifier::GetConnectionSubtype(); |
| 129 } | 163 } |
| 130 | 164 |
| 131 } // namespace net | 165 } // namespace net |
| OLD | NEW |