summaryrefslogtreecommitdiffstats
path: root/net/dns/dns_config_service_win_unittest.cc
diff options
context:
space:
mode:
authorszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-16 17:13:11 +0000
committerszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-16 17:13:11 +0000
commitb4481b2296ce6035e52db00c8011cf20c165d7b6 (patch)
tree6a5b751c14fdc713b4ae76e407ac29c82d9f1df5 /net/dns/dns_config_service_win_unittest.cc
parente1c39ae523ad5cce2f6d8d9e0dd177c2d5358676 (diff)
downloadchromium_src-b4481b2296ce6035e52db00c8011cf20c165d7b6.zip
chromium_src-b4481b2296ce6035e52db00c8011cf20c165d7b6.tar.gz
chromium_src-b4481b2296ce6035e52db00c8011cf20c165d7b6.tar.bz2
[net/dns] Refactoring of DnsConfigService.
- Replaces Observer with Callback. - The Callback is run within 100ms of any config change, not only on successful read. It is also run on errors in watches (registry and files). This allows HostResolverImpl to withdraw from using DnsTask until DnsConfig is read successfully. - Moves DnsHostsReader to dns_hosts.{h,cc}). - Handles missing HOSTS files. - Respects network adapter binding order in DnsConfigServiceWin. - Adds NetLog source for DnsConfig-related events. BUG=112856, 115460, 115494 TEST=./net_unittests --gtest_filter=DnsConfig* Review URL: http://codereview.chromium.org/9597029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127190 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/dns/dns_config_service_win_unittest.cc')
-rw-r--r--net/dns/dns_config_service_win_unittest.cc31
1 files changed, 23 insertions, 8 deletions
diff --git a/net/dns/dns_config_service_win_unittest.cc b/net/dns/dns_config_service_win_unittest.cc
index 269bb55..fa5da54 100644
--- a/net/dns/dns_config_service_win_unittest.cc
+++ b/net/dns/dns_config_service_win_unittest.cc
@@ -4,6 +4,7 @@
#include "net/dns/dns_config_service_win.h"
+#include "base/logging.h"
#include "base/win/windows_version.h"
#include "net/dns/dns_protocol.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -38,7 +39,7 @@ TEST(DnsConfigServiceWinTest, ParseSearchList) {
for (const char* const* output = t.output; *output; ++output) {
expected_output.push_back(*output);
}
- bool result = ParseSearchList(t.input, &actual_output);
+ bool result = internal::ParseSearchList(t.input, &actual_output);
if (!expected_output.empty()) {
EXPECT_TRUE(result);
EXPECT_EQ(expected_output, actual_output);
@@ -143,6 +144,19 @@ TEST(DnsConfigServiceWinTest, ConvertAdapterAddresses) {
"chromium.org",
{ 1024, 24 },
},
+ { // Use the preferred adapter (first in binding order).
+ {
+ { IF_TYPE_SOFTWARE_LOOPBACK, IfOperStatusUp, L"funnyloop",
+ { "2.0.0.2" } },
+ { IF_TYPE_FASTETHER, IfOperStatusUp, L"example.com",
+ { "1.0.0.1" } },
+ { IF_TYPE_USB, IfOperStatusUp, L"chromium.org",
+ { "10.0.0.10", "2001:FFFF::1111" } },
+ { 0 },
+ },
+ { "1.0.0.1" },
+ "example.com",
+ },
{ // No usable nameservers.
{
{ IF_TYPE_SOFTWARE_LOOPBACK, IfOperStatusUp, L"localhost",
@@ -157,7 +171,7 @@ TEST(DnsConfigServiceWinTest, ConvertAdapterAddresses) {
for (size_t i = 0; i < arraysize(cases); ++i) {
const TestCase& t = cases[i];
- DnsSystemSettings settings = {
+ internal::DnsSystemSettings settings = {
CreateAdapterAddresses(t.input_adapters),
// Default settings for the rest.
};
@@ -172,7 +186,7 @@ TEST(DnsConfigServiceWinTest, ConvertAdapterAddresses) {
}
DnsConfig config;
- bool result = ConvertSettingsToDnsConfig(settings, &config);
+ bool result = internal::ConvertSettingsToDnsConfig(settings, &config);
bool expected_result = !expected_nameservers.empty();
ASSERT_EQ(expected_result, result);
EXPECT_EQ(expected_nameservers, config.nameservers);
@@ -190,7 +204,7 @@ TEST(DnsConfigServiceWinTest, ConvertSuffixSearch) {
};
const struct TestCase {
- DnsSystemSettings input_settings;
+ internal::DnsSystemSettings input_settings;
std::string expected_search[5];
} cases[] = {
{ // Policy SearchList override.
@@ -320,7 +334,8 @@ TEST(DnsConfigServiceWinTest, ConvertSuffixSearch) {
for (size_t i = 0; i < arraysize(cases); ++i) {
const TestCase& t = cases[i];
DnsConfig config;
- ASSERT_TRUE(ConvertSettingsToDnsConfig(t.input_settings, &config));
+ ASSERT_TRUE(internal::ConvertSettingsToDnsConfig(t.input_settings,
+ &config));
std::vector<std::string> expected_search;
for (size_t j = 0; !t.expected_search[j].empty(); ++j) {
expected_search.push_back(t.expected_search[j]);
@@ -339,7 +354,7 @@ TEST(DnsConfigServiceWinTest, AppendToMultiLabelName) {
bool default_value = (base::win::GetVersion() < base::win::VERSION_VISTA);
const struct TestCase {
- DnsSystemSettings::RegDword input;
+ internal::DnsSystemSettings::RegDword input;
bool expected_output;
} cases[] = {
{ { true, 0 }, false },
@@ -349,7 +364,7 @@ TEST(DnsConfigServiceWinTest, AppendToMultiLabelName) {
for (size_t i = 0; i < arraysize(cases); ++i) {
const TestCase& t = cases[i];
- DnsSystemSettings settings = {
+ internal::DnsSystemSettings settings = {
CreateAdapterAddresses(infos),
{ false }, { false }, { false },
{ { false }, { false } },
@@ -358,7 +373,7 @@ TEST(DnsConfigServiceWinTest, AppendToMultiLabelName) {
t.input,
};
DnsConfig config;
- ASSERT_TRUE(ConvertSettingsToDnsConfig(settings, &config));
+ ASSERT_TRUE(internal::ConvertSettingsToDnsConfig(settings, &config));
EXPECT_EQ(config.append_to_multi_label_name, t.expected_output);
}
}