Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: net/dns/dns_config_service_win_unittest.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/dns/dns_config_service_win.cc ('k') | net/dns/dns_hosts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/dns/dns_config_service_win.h" 5 #include "net/dns/dns_config_service_win.h"
6 6
7 #include "base/basictypes.h"
8 #include "base/logging.h" 7 #include "base/logging.h"
9 #include "base/win/windows_version.h" 8 #include "base/win/windows_version.h"
10 #include "net/dns/dns_protocol.h" 9 #include "net/dns/dns_protocol.h"
11 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
12 11
13 namespace net { 12 namespace net {
14 13
15 namespace { 14 namespace {
16 15
17 TEST(DnsConfigServiceWinTest, ParseSearchList) { 16 TEST(DnsConfigServiceWinTest, ParseSearchList) {
(...skipping 27 matching lines...) Expand all
45 EXPECT_FALSE(result) << "Unexpected parse success on " << t.input; 44 EXPECT_FALSE(result) << "Unexpected parse success on " << t.input;
46 } 45 }
47 } 46 }
48 } 47 }
49 48
50 struct AdapterInfo { 49 struct AdapterInfo {
51 IFTYPE if_type; 50 IFTYPE if_type;
52 IF_OPER_STATUS oper_status; 51 IF_OPER_STATUS oper_status;
53 const WCHAR* dns_suffix; 52 const WCHAR* dns_suffix;
54 std::string dns_server_addresses[4]; // Empty string indicates end. 53 std::string dns_server_addresses[4]; // Empty string indicates end.
55 uint16 ports[4]; 54 uint16_t ports[4];
56 }; 55 };
57 56
58 scoped_ptr<IP_ADAPTER_ADDRESSES, base::FreeDeleter> CreateAdapterAddresses( 57 scoped_ptr<IP_ADAPTER_ADDRESSES, base::FreeDeleter> CreateAdapterAddresses(
59 const AdapterInfo* infos) { 58 const AdapterInfo* infos) {
60 size_t num_adapters = 0; 59 size_t num_adapters = 0;
61 size_t num_addresses = 0; 60 size_t num_addresses = 0;
62 for (size_t i = 0; infos[i].if_type; ++i) { 61 for (size_t i = 0; infos[i].if_type; ++i) {
63 ++num_adapters; 62 ++num_adapters;
64 for (size_t j = 0; !infos[i].dns_server_addresses[j].empty(); ++j) { 63 for (size_t j = 0; !infos[i].dns_server_addresses[j].empty(); ++j) {
65 ++num_addresses; 64 ++num_addresses;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 109
111 return heap.Pass(); 110 return heap.Pass();
112 } 111 }
113 112
114 TEST(DnsConfigServiceWinTest, ConvertAdapterAddresses) { 113 TEST(DnsConfigServiceWinTest, ConvertAdapterAddresses) {
115 // Check nameservers and connection-specific suffix. 114 // Check nameservers and connection-specific suffix.
116 const struct TestCase { 115 const struct TestCase {
117 AdapterInfo input_adapters[4]; // |if_type| == 0 indicates end. 116 AdapterInfo input_adapters[4]; // |if_type| == 0 indicates end.
118 std::string expected_nameservers[4]; // Empty string indicates end. 117 std::string expected_nameservers[4]; // Empty string indicates end.
119 std::string expected_suffix; 118 std::string expected_suffix;
120 uint16 expected_ports[4]; 119 uint16_t expected_ports[4];
121 } cases[] = { 120 } cases[] = {
122 { // Ignore loopback and inactive adapters. 121 { // Ignore loopback and inactive adapters.
123 { 122 {
124 { IF_TYPE_SOFTWARE_LOOPBACK, IfOperStatusUp, L"funnyloop", 123 { IF_TYPE_SOFTWARE_LOOPBACK, IfOperStatusUp, L"funnyloop",
125 { "2.0.0.2" } }, 124 { "2.0.0.2" } },
126 { IF_TYPE_FASTETHER, IfOperStatusDormant, L"example.com", 125 { IF_TYPE_FASTETHER, IfOperStatusDormant, L"example.com",
127 { "1.0.0.1" } }, 126 { "1.0.0.1" } },
128 { IF_TYPE_USB, IfOperStatusUp, L"chromium.org", 127 { IF_TYPE_USB, IfOperStatusUp, L"chromium.org",
129 { "10.0.0.10", "2001:FFFF::1111" } }, 128 { "10.0.0.10", "2001:FFFF::1111" } },
130 { 0 }, 129 { 0 },
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 }; 168 };
170 169
171 for (const auto& t : cases) { 170 for (const auto& t : cases) {
172 internal::DnsSystemSettings settings; 171 internal::DnsSystemSettings settings;
173 settings.addresses = CreateAdapterAddresses(t.input_adapters); 172 settings.addresses = CreateAdapterAddresses(t.input_adapters);
174 // Default settings for the rest. 173 // Default settings for the rest.
175 std::vector<IPEndPoint> expected_nameservers; 174 std::vector<IPEndPoint> expected_nameservers;
176 for (size_t j = 0; !t.expected_nameservers[j].empty(); ++j) { 175 for (size_t j = 0; !t.expected_nameservers[j].empty(); ++j) {
177 IPAddressNumber ip; 176 IPAddressNumber ip;
178 ASSERT_TRUE(ParseIPLiteralToNumber(t.expected_nameservers[j], &ip)); 177 ASSERT_TRUE(ParseIPLiteralToNumber(t.expected_nameservers[j], &ip));
179 uint16 port = t.expected_ports[j]; 178 uint16_t port = t.expected_ports[j];
180 if (!port) 179 if (!port)
181 port = dns_protocol::kDefaultPort; 180 port = dns_protocol::kDefaultPort;
182 expected_nameservers.push_back(IPEndPoint(ip, port)); 181 expected_nameservers.push_back(IPEndPoint(ip, port));
183 } 182 }
184 183
185 DnsConfig config; 184 DnsConfig config;
186 internal::ConfigParseWinResult result = 185 internal::ConfigParseWinResult result =
187 internal::ConvertSettingsToDnsConfig(settings, &config); 186 internal::ConvertSettingsToDnsConfig(settings, &config);
188 internal::ConfigParseWinResult expected_result = 187 internal::ConfigParseWinResult expected_result =
189 expected_nameservers.empty() ? internal::CONFIG_PARSE_WIN_NO_NAMESERVERS 188 expected_nameservers.empty() ? internal::CONFIG_PARSE_WIN_NO_NAMESERVERS
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 EXPECT_EQ(t.unhandled_options, config.unhandled_options); 442 EXPECT_EQ(t.unhandled_options, config.unhandled_options);
444 EXPECT_EQ(t.have_nrpt, config.use_local_ipv6); 443 EXPECT_EQ(t.have_nrpt, config.use_local_ipv6);
445 } 444 }
446 } 445 }
447 446
448 447
449 } // namespace 448 } // namespace
450 449
451 } // namespace net 450 } // namespace net
452 451
OLDNEW
« no previous file with comments | « net/dns/dns_config_service_win.cc ('k') | net/dns/dns_hosts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698