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/network_interfaces.h" | 5 #include "net/base/network_interfaces.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 #include <string> | 8 #include <string> |
9 #include <unordered_set> | 9 #include <unordered_set> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... | |
29 #include <netinet/in_var.h> | 29 #include <netinet/in_var.h> |
30 #endif // !OS_IOS | 30 #endif // !OS_IOS |
31 #endif // OS_MACOSX | 31 #endif // OS_MACOSX |
32 #endif // !OS_NACL && !OS_WIN | 32 #endif // !OS_NACL && !OS_WIN |
33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
34 #include "url/gurl.h" | 34 #include "url/gurl.h" |
35 | 35 |
36 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
37 #include <iphlpapi.h> | 37 #include <iphlpapi.h> |
38 #include <objbase.h> | 38 #include <objbase.h> |
39 #include "base/win/windows_version.h" | 39 #include "base/win/windows_version.h" |
mmenke
2016/05/17 11:25:23
No longer needed.
maksims (do not use this acc)
2016/05/18 09:12:06
Done.
| |
40 #endif // OS_WIN | 40 #endif // OS_WIN |
41 | 41 |
42 #if !defined(OS_MACOSX) && !defined(OS_NACL) && !defined(OS_WIN) | 42 #if !defined(OS_MACOSX) && !defined(OS_NACL) && !defined(OS_WIN) |
43 #include "net/base/address_tracker_linux.h" | 43 #include "net/base/address_tracker_linux.h" |
44 #endif // !OS_MACOSX && !OS_NACL && !OS_WIN | 44 #endif // !OS_MACOSX && !OS_NACL && !OS_WIN |
45 | 45 |
46 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
47 #include "net/base/network_interfaces_win.h" | 47 #include "net/base/network_interfaces_win.h" |
48 #else // OS_WIN | 48 #else // OS_WIN |
49 #include "net/base/network_interfaces_posix.h" | 49 #include "net/base/network_interfaces_posix.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 typedef NETIO_STATUS (WINAPI* ConvertInterfaceIndexToLuid)(NET_IFINDEX, | 144 typedef NETIO_STATUS (WINAPI* ConvertInterfaceIndexToLuid)(NET_IFINDEX, |
145 PNET_LUID); | 145 PNET_LUID); |
146 ConvertInterfaceIndexToLuid interface_to_luid = | 146 ConvertInterfaceIndexToLuid interface_to_luid = |
147 reinterpret_cast<ConvertInterfaceIndexToLuid>( | 147 reinterpret_cast<ConvertInterfaceIndexToLuid>( |
148 phlpapi_lib.GetFunctionPointer("ConvertInterfaceIndexToLuid")); | 148 phlpapi_lib.GetFunctionPointer("ConvertInterfaceIndexToLuid")); |
149 | 149 |
150 typedef NETIO_STATUS (WINAPI* ConvertInterfaceLuidToGuid)(NET_LUID*, | 150 typedef NETIO_STATUS (WINAPI* ConvertInterfaceLuidToGuid)(NET_LUID*, |
151 GUID*); | 151 GUID*); |
152 ConvertInterfaceLuidToGuid luid_to_guid = | 152 ConvertInterfaceLuidToGuid luid_to_guid = |
153 reinterpret_cast<ConvertInterfaceLuidToGuid>( | 153 reinterpret_cast<ConvertInterfaceLuidToGuid>( |
154 phlpapi_lib.GetFunctionPointer("ConvertInterfaceLuidToGuid")); | 154 phlpapi_lib.GetFunctionPointer("ConvertInterfaceLuidToGuid")); |
mattmenke_gmail.com
2016/05/17 12:34:39
If you look at these, right now, we're trying to l
| |
155 | 155 |
156 if (interface_to_luid && luid_to_guid) { | 156 if (interface_to_luid && luid_to_guid) { |
mmenke
2016/05/17 11:25:23
I think these should both be EXPECT_TRUE, now?
Ac
maksims (do not use this acc)
2016/05/17 11:47:48
Did not get the part about static linking. What do
| |
157 NET_LUID luid; | 157 NET_LUID luid; |
158 EXPECT_EQ(static_cast<DWORD>(NO_ERROR), | 158 EXPECT_EQ(static_cast<DWORD>(NO_ERROR), |
159 interface_to_luid(it->interface_index, &luid)); | 159 interface_to_luid(it->interface_index, &luid)); |
160 GUID guid; | 160 GUID guid; |
161 EXPECT_EQ(static_cast<DWORD>(NO_ERROR), luid_to_guid(&luid, &guid)); | 161 EXPECT_EQ(static_cast<DWORD>(NO_ERROR), luid_to_guid(&luid, &guid)); |
162 LPOLESTR name; | 162 LPOLESTR name; |
163 StringFromCLSID(guid, &name); | 163 StringFromCLSID(guid, &name); |
164 EXPECT_STREQ(base::UTF8ToWide(it->name).c_str(), name); | 164 EXPECT_STREQ(base::UTF8ToWide(it->name).c_str(), name); |
165 CoTaskMemFree(name); | 165 CoTaskMemFree(name); |
166 continue; | 166 continue; |
167 } else { | |
168 EXPECT_LT(base::win::GetVersion(), base::win::VERSION_VISTA); | |
169 EXPECT_LT(it->interface_index, 1u << 24u); // Must fit 0.x.x.x. | |
170 EXPECT_NE(it->interface_index, 0u); // 0 means to use default. | |
171 } | 167 } |
168 | |
172 if (it->type == NetworkChangeNotifier::CONNECTION_WIFI) { | 169 if (it->type == NetworkChangeNotifier::CONNECTION_WIFI) { |
173 EXPECT_NE(WIFI_PHY_LAYER_PROTOCOL_NONE, GetWifiPHYLayerProtocol()); | 170 EXPECT_NE(WIFI_PHY_LAYER_PROTOCOL_NONE, GetWifiPHYLayerProtocol()); |
174 } | 171 } |
175 #elif !defined(OS_ANDROID) | 172 #elif !defined(OS_ANDROID) |
176 char name[IF_NAMESIZE]; | 173 char name[IF_NAMESIZE]; |
177 EXPECT_TRUE(if_indextoname(it->interface_index, name)); | 174 EXPECT_TRUE(if_indextoname(it->interface_index, name)); |
178 EXPECT_STREQ(it->name.c_str(), name); | 175 EXPECT_STREQ(it->name.c_str(), name); |
179 #endif | 176 #endif |
180 } | 177 } |
181 } | 178 } |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
742 // We can't check the result of GetHostName() directly, since the result | 739 // We can't check the result of GetHostName() directly, since the result |
743 // will differ across machines. Our goal here is to simply exercise the | 740 // will differ across machines. Our goal here is to simply exercise the |
744 // code path, and check that things "look about right". | 741 // code path, and check that things "look about right". |
745 std::string hostname = GetHostName(); | 742 std::string hostname = GetHostName(); |
746 EXPECT_FALSE(hostname.empty()); | 743 EXPECT_FALSE(hostname.empty()); |
747 } | 744 } |
748 | 745 |
749 } // namespace | 746 } // namespace |
750 | 747 |
751 } // namespace net | 748 } // namespace net |
OLD | NEW |