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

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

Issue 10543168: [net/dns] Instrument DnsConfigService to measure performance and failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 8 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « net/dns/dns_config_service_win.cc ('k') | no next file » | 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/logging.h" 7 #include "base/logging.h"
8 #include "base/win/windows_version.h" 8 #include "base/win/windows_version.h"
9 #include "net/dns/dns_protocol.h" 9 #include "net/dns/dns_protocol.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 for (size_t j = 0; !t.expected_nameservers[j].empty(); ++j) { 179 for (size_t j = 0; !t.expected_nameservers[j].empty(); ++j) {
180 IPAddressNumber ip; 180 IPAddressNumber ip;
181 ASSERT_TRUE(ParseIPLiteralToNumber(t.expected_nameservers[j], &ip)); 181 ASSERT_TRUE(ParseIPLiteralToNumber(t.expected_nameservers[j], &ip));
182 int port = t.expected_ports[j]; 182 int port = t.expected_ports[j];
183 if (!port) 183 if (!port)
184 port = dns_protocol::kDefaultPort; 184 port = dns_protocol::kDefaultPort;
185 expected_nameservers.push_back(IPEndPoint(ip, port)); 185 expected_nameservers.push_back(IPEndPoint(ip, port));
186 } 186 }
187 187
188 DnsConfig config; 188 DnsConfig config;
189 bool result = internal::ConvertSettingsToDnsConfig(settings, &config); 189 internal::ConfigParseWinResult result =
190 bool expected_result = !expected_nameservers.empty(); 190 internal::ConvertSettingsToDnsConfig(settings, &config);
191 ASSERT_EQ(expected_result, result); 191 internal::ConfigParseWinResult expected_result =
192 expected_nameservers.empty() ? internal::CONFIG_PARSE_WIN_NO_NAMESERVERS
193 : internal::CONFIG_PARSE_WIN_OK;
194 EXPECT_EQ(expected_result, result);
192 EXPECT_EQ(expected_nameservers, config.nameservers); 195 EXPECT_EQ(expected_nameservers, config.nameservers);
193 if (result) { 196 if (result == internal::CONFIG_PARSE_WIN_OK) {
194 ASSERT_EQ(1u, config.search.size()); 197 ASSERT_EQ(1u, config.search.size());
195 EXPECT_EQ(t.expected_suffix, config.search[0]); 198 EXPECT_EQ(t.expected_suffix, config.search[0]);
196 } 199 }
197 } 200 }
198 } 201 }
199 202
200 TEST(DnsConfigServiceWinTest, ConvertSuffixSearch) { 203 TEST(DnsConfigServiceWinTest, ConvertSuffixSearch) {
201 AdapterInfo infos[2] = { 204 AdapterInfo infos[2] = {
202 { IF_TYPE_USB, IfOperStatusUp, L"connection.suffix", { "1.0.0.1" } }, 205 { IF_TYPE_USB, IfOperStatusUp, L"connection.suffix", { "1.0.0.1" } },
203 { 0 }, 206 { 0 },
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 { { false }, { true, 3 } }, 371 { { false }, { true, 3 } },
369 { { true, 0 }, { true, 3 } }, 372 { { true, 0 }, { true, 3 } },
370 }, 373 },
371 { "a.b.c.d.e", "connection.suffix" }, 374 { "a.b.c.d.e", "connection.suffix" },
372 }, 375 },
373 }; 376 };
374 377
375 for (size_t i = 0; i < arraysize(cases); ++i) { 378 for (size_t i = 0; i < arraysize(cases); ++i) {
376 const TestCase& t = cases[i]; 379 const TestCase& t = cases[i];
377 DnsConfig config; 380 DnsConfig config;
378 ASSERT_TRUE(internal::ConvertSettingsToDnsConfig(t.input_settings, 381 EXPECT_EQ(internal::CONFIG_PARSE_WIN_OK,
379 &config)); 382 internal::ConvertSettingsToDnsConfig(t.input_settings, &config));
380 std::vector<std::string> expected_search; 383 std::vector<std::string> expected_search;
381 for (size_t j = 0; !t.expected_search[j].empty(); ++j) { 384 for (size_t j = 0; !t.expected_search[j].empty(); ++j) {
382 expected_search.push_back(t.expected_search[j]); 385 expected_search.push_back(t.expected_search[j]);
383 } 386 }
384 EXPECT_EQ(expected_search, config.search); 387 EXPECT_EQ(expected_search, config.search);
385 } 388 }
386 } 389 }
387 390
388 TEST(DnsConfigServiceWinTest, AppendToMultiLabelName) { 391 TEST(DnsConfigServiceWinTest, AppendToMultiLabelName) {
389 AdapterInfo infos[2] = { 392 AdapterInfo infos[2] = {
(...skipping 17 matching lines...) Expand all
407 const TestCase& t = cases[i]; 410 const TestCase& t = cases[i];
408 internal::DnsSystemSettings settings = { 411 internal::DnsSystemSettings settings = {
409 CreateAdapterAddresses(infos), 412 CreateAdapterAddresses(infos),
410 { false }, { false }, { false }, { false }, 413 { false }, { false }, { false }, { false },
411 { { false }, { false } }, 414 { { false }, { false } },
412 { { false }, { false } }, 415 { { false }, { false } },
413 { { false }, { false } }, 416 { { false }, { false } },
414 t.input, 417 t.input,
415 }; 418 };
416 DnsConfig config; 419 DnsConfig config;
417 ASSERT_TRUE(internal::ConvertSettingsToDnsConfig(settings, &config)); 420 EXPECT_EQ(internal::CONFIG_PARSE_WIN_OK,
421 internal::ConvertSettingsToDnsConfig(settings, &config));
418 EXPECT_EQ(config.append_to_multi_label_name, t.expected_output); 422 EXPECT_EQ(config.append_to_multi_label_name, t.expected_output);
419 } 423 }
420 } 424 }
421 425
422 } // namespace 426 } // namespace
423 427
424 } // namespace net 428 } // namespace net
425 429
OLDNEW
« no previous file with comments | « net/dns/dns_config_service_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698