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

Unified Diff: net/dns/dns_config_service_win_unittest.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: net/dns/dns_config_service_win_unittest.cc
diff --git a/net/dns/dns_config_service_win_unittest.cc b/net/dns/dns_config_service_win_unittest.cc
index 7ac01d1e536fd1e431c85e74f77dcc9a96ee60fa..4219d82b425f303f2b04ff1e48435d94bc969eda 100644
--- a/net/dns/dns_config_service_win_unittest.cc
+++ b/net/dns/dns_config_service_win_unittest.cc
@@ -19,17 +19,17 @@ TEST(DnsConfigServiceWinTest, ParseSearchList) {
const wchar_t* input;
const char* output[4]; // NULL-terminated, empty if expected false
} cases[] = {
- { L"chromium.org", { "chromium.org", NULL } },
- { L"chromium.org,org", { "chromium.org", "org", NULL } },
- // Empty suffixes terminate the list
- { L"crbug.com,com,,org", { "crbug.com", "com", NULL } },
- // IDN are converted to punycode
- { L"\u017c\xf3\u0142ta.pi\u0119\u015b\u0107.pl,pl",
- { "xn--ta-4ja03asj.xn--pi-wla5e0q.pl", "pl", NULL } },
- // Empty search list is invalid
- { L"", { NULL } },
- { L",,", { NULL } },
- };
+ {L"chromium.org", {"chromium.org", NULL}},
+ {L"chromium.org,org", {"chromium.org", "org", NULL}},
+ // Empty suffixes terminate the list
+ {L"crbug.com,com,,org", {"crbug.com", "com", NULL}},
+ // IDN are converted to punycode
+ {L"\u017c\xf3\u0142ta.pi\u0119\u015b\u0107.pl,pl",
+ {"xn--ta-4ja03asj.xn--pi-wla5e0q.pl", "pl", NULL}},
+ // Empty search list is invalid
+ {L"", {NULL}},
+ {L",,", {NULL}},
+ };
std::vector<std::string> actual_output, expected_output;
for (unsigned i = 0; i < arraysize(cases); ++i) {
@@ -122,60 +122,73 @@ TEST(DnsConfigServiceWinTest, ConvertAdapterAddresses) {
std::string expected_suffix;
int expected_ports[4];
} cases[] = {
- { // Ignore loopback and inactive adapters.
- {
- { IF_TYPE_SOFTWARE_LOOPBACK, IfOperStatusUp, L"funnyloop",
- { "2.0.0.2" } },
- { IF_TYPE_FASTETHER, IfOperStatusDormant, L"example.com",
- { "1.0.0.1" } },
- { IF_TYPE_USB, IfOperStatusUp, L"chromium.org",
- { "10.0.0.10", "2001:FFFF::1111" } },
- { 0 },
- },
- { "10.0.0.10", "2001:FFFF::1111" },
- "chromium.org",
- },
- { // Respect configured ports.
- {
- { IF_TYPE_USB, IfOperStatusUp, L"chromium.org",
- { "10.0.0.10", "2001:FFFF::1111" }, { 1024, 24 } },
- { 0 },
- },
- { "10.0.0.10", "2001:FFFF::1111" },
- "chromium.org",
- { 1024, 24 },
- },
- { // Use the preferred adapter (first in binding order) and filter
- // stateless DNS discovery addresses.
- {
- { IF_TYPE_SOFTWARE_LOOPBACK, IfOperStatusUp, L"funnyloop",
- { "2.0.0.2" } },
- { IF_TYPE_FASTETHER, IfOperStatusUp, L"example.com",
- { "1.0.0.1", "fec0:0:0:ffff::2", "8.8.8.8" } },
- { IF_TYPE_USB, IfOperStatusUp, L"chromium.org",
- { "10.0.0.10", "2001:FFFF::1111" } },
- { 0 },
- },
- { "1.0.0.1", "8.8.8.8" },
- "example.com",
- },
- { // No usable adapters.
- {
- { IF_TYPE_SOFTWARE_LOOPBACK, IfOperStatusUp, L"localhost",
- { "2.0.0.2" } },
- { IF_TYPE_FASTETHER, IfOperStatusDormant, L"example.com",
- { "1.0.0.1" } },
- { IF_TYPE_USB, IfOperStatusUp, L"chromium.org" },
- { 0 },
- },
- },
- };
+ {// Ignore loopback and inactive adapters.
+ {
+ {IF_TYPE_SOFTWARE_LOOPBACK,
+ IfOperStatusUp,
+ L"funnyloop",
+ {"2.0.0.2"}},
+ {IF_TYPE_FASTETHER, IfOperStatusDormant, L"example.com", {"1.0.0.1"}},
+ {IF_TYPE_USB,
+ IfOperStatusUp,
+ L"chromium.org",
+ {"10.0.0.10", "2001:FFFF::1111"}},
+ {0},
+ },
+ {"10.0.0.10", "2001:FFFF::1111"},
+ "chromium.org",
+ },
+ {// Respect configured ports.
+ {
+ {IF_TYPE_USB,
+ IfOperStatusUp,
+ L"chromium.org",
+ {"10.0.0.10", "2001:FFFF::1111"},
+ {1024, 24}},
+ {0},
+ },
+ {"10.0.0.10", "2001:FFFF::1111"},
+ "chromium.org",
+ {1024, 24},
+ },
+ {// Use the preferred adapter (first in binding order) and filter
+ // stateless DNS discovery addresses.
+ {
+ {IF_TYPE_SOFTWARE_LOOPBACK,
+ IfOperStatusUp,
+ L"funnyloop",
+ {"2.0.0.2"}},
+ {IF_TYPE_FASTETHER,
+ IfOperStatusUp,
+ L"example.com",
+ {"1.0.0.1", "fec0:0:0:ffff::2", "8.8.8.8"}},
+ {IF_TYPE_USB,
+ IfOperStatusUp,
+ L"chromium.org",
+ {"10.0.0.10", "2001:FFFF::1111"}},
+ {0},
+ },
+ {"1.0.0.1", "8.8.8.8"},
+ "example.com",
+ },
+ {// No usable adapters.
+ {
+ {IF_TYPE_SOFTWARE_LOOPBACK,
+ IfOperStatusUp,
+ L"localhost",
+ {"2.0.0.2"}},
+ {IF_TYPE_FASTETHER, IfOperStatusDormant, L"example.com", {"1.0.0.1"}},
+ {IF_TYPE_USB, IfOperStatusUp, L"chromium.org"},
+ {0},
+ },
+ },
+ };
for (size_t i = 0; i < arraysize(cases); ++i) {
const TestCase& t = cases[i];
internal::DnsSystemSettings settings = {
- CreateAdapterAddresses(t.input_adapters),
- // Default settings for the rest.
+ CreateAdapterAddresses(t.input_adapters),
+ // Default settings for the rest.
};
std::vector<IPEndPoint> expected_nameservers;
for (size_t j = 0; !t.expected_nameservers[j].empty(); ++j) {
@@ -192,7 +205,7 @@ TEST(DnsConfigServiceWinTest, ConvertAdapterAddresses) {
internal::ConvertSettingsToDnsConfig(settings, &config);
internal::ConfigParseWinResult expected_result =
expected_nameservers.empty() ? internal::CONFIG_PARSE_WIN_NO_NAMESERVERS
- : internal::CONFIG_PARSE_WIN_OK;
+ : internal::CONFIG_PARSE_WIN_OK;
EXPECT_EQ(expected_result, result);
EXPECT_EQ(expected_nameservers, config.nameservers);
if (result == internal::CONFIG_PARSE_WIN_OK) {
@@ -204,178 +217,177 @@ TEST(DnsConfigServiceWinTest, ConvertAdapterAddresses) {
TEST(DnsConfigServiceWinTest, ConvertSuffixSearch) {
AdapterInfo infos[2] = {
- { IF_TYPE_USB, IfOperStatusUp, L"connection.suffix", { "1.0.0.1" } },
- { 0 },
+ {IF_TYPE_USB, IfOperStatusUp, L"connection.suffix", {"1.0.0.1"}}, {0},
};
const struct TestCase {
internal::DnsSystemSettings input_settings;
std::string expected_search[5];
} cases[] = {
- { // Policy SearchList override.
- {
- CreateAdapterAddresses(infos),
- { true, L"policy.searchlist.a,policy.searchlist.b" },
- { true, L"tcpip.searchlist.a,tcpip.searchlist.b" },
- { true, L"tcpip.domain" },
- { true, L"primary.dns.suffix" },
- },
- { "policy.searchlist.a", "policy.searchlist.b" },
- },
- { // User-specified SearchList override.
- {
- CreateAdapterAddresses(infos),
- { false },
- { true, L"tcpip.searchlist.a,tcpip.searchlist.b" },
- { true, L"tcpip.domain" },
- { true, L"primary.dns.suffix" },
- },
- { "tcpip.searchlist.a", "tcpip.searchlist.b" },
- },
- { // Void SearchList. Using tcpip.domain
- {
- CreateAdapterAddresses(infos),
- { true, L",bad.searchlist,parsed.as.empty" },
- { true, L"tcpip.searchlist,good.but.overridden" },
- { true, L"tcpip.domain" },
- { false },
- },
- { "tcpip.domain", "connection.suffix" },
- },
- { // Void SearchList. Using primary.dns.suffix
- {
- CreateAdapterAddresses(infos),
- { true, L",bad.searchlist,parsed.as.empty" },
- { true, L"tcpip.searchlist,good.but.overridden" },
- { true, L"tcpip.domain" },
- { true, L"primary.dns.suffix" },
- },
- { "primary.dns.suffix", "connection.suffix" },
- },
- { // Void SearchList. Using tcpip.domain when primary.dns.suffix is empty
- {
- CreateAdapterAddresses(infos),
- { true, L",bad.searchlist,parsed.as.empty" },
- { true, L"tcpip.searchlist,good.but.overridden" },
- { true, L"tcpip.domain" },
- { true, L"" },
- },
- { "tcpip.domain", "connection.suffix" },
- },
- { // Void SearchList. Using tcpip.domain when primary.dns.suffix is NULL
- {
- CreateAdapterAddresses(infos),
- { true, L",bad.searchlist,parsed.as.empty" },
- { true, L"tcpip.searchlist,good.but.overridden" },
- { true, L"tcpip.domain" },
- { true },
- },
- { "tcpip.domain", "connection.suffix" },
- },
- { // No primary suffix. Devolution does not matter.
- {
- CreateAdapterAddresses(infos),
- { false },
- { false },
- { true },
- { true },
- { { true, 1 }, { true, 2 } },
- },
- { "connection.suffix" },
- },
- { // Devolution enabled by policy, level by dnscache.
- {
- CreateAdapterAddresses(infos),
- { false },
- { false },
- { true, L"a.b.c.d.e" },
- { false },
- { { true, 1 }, { false } }, // policy_devolution: enabled, level
- { { true, 0 }, { true, 3 } }, // dnscache_devolution
- { { true, 0 }, { true, 1 } }, // tcpip_devolution
- },
- { "a.b.c.d.e", "connection.suffix", "b.c.d.e", "c.d.e" },
- },
- { // Devolution enabled by dnscache, level by policy.
- {
- CreateAdapterAddresses(infos),
- { false },
- { false },
- { true, L"a.b.c.d.e" },
- { true, L"f.g.i.l.j" },
- { { false }, { true, 4 } },
- { { true, 1 }, { false } },
- { { true, 0 }, { true, 3 } },
- },
- { "f.g.i.l.j", "connection.suffix", "g.i.l.j" },
- },
- { // Devolution enabled by default.
- {
- CreateAdapterAddresses(infos),
- { false },
- { false },
- { true, L"a.b.c.d.e" },
- { false },
- { { false }, { false } },
- { { false }, { true, 3 } },
- { { false }, { true, 1 } },
- },
- { "a.b.c.d.e", "connection.suffix", "b.c.d.e", "c.d.e" },
- },
- { // Devolution enabled at level = 2, but nothing to devolve.
- {
- CreateAdapterAddresses(infos),
- { false },
- { false },
- { true, L"a.b" },
- { false },
- { { false }, { false } },
- { { false }, { true, 2 } },
- { { false }, { true, 2 } },
- },
- { "a.b", "connection.suffix" },
- },
- { // Devolution disabled when no explicit level.
- // Windows XP and Vista use a default level = 2, but we don't.
- {
- CreateAdapterAddresses(infos),
- { false },
- { false },
- { true, L"a.b.c.d.e" },
- { false },
- { { true, 1 }, { false } },
- { { true, 1 }, { false } },
- { { true, 1 }, { false } },
- },
- { "a.b.c.d.e", "connection.suffix" },
- },
- { // Devolution disabled by policy level.
- {
- CreateAdapterAddresses(infos),
- { false },
- { false },
- { true, L"a.b.c.d.e" },
- { false },
- { { false }, { true, 1 } },
- { { true, 1 }, { true, 3 } },
- { { true, 1 }, { true, 4 } },
- },
- { "a.b.c.d.e", "connection.suffix" },
- },
- { // Devolution disabled by user setting.
- {
- CreateAdapterAddresses(infos),
- { false },
- { false },
- { true, L"a.b.c.d.e" },
- { false },
- { { false }, { true, 3 } },
- { { false }, { true, 3 } },
- { { true, 0 }, { true, 3 } },
- },
- { "a.b.c.d.e", "connection.suffix" },
- },
- };
+ {// Policy SearchList override.
+ {
+ CreateAdapterAddresses(infos),
+ {true, L"policy.searchlist.a,policy.searchlist.b"},
+ {true, L"tcpip.searchlist.a,tcpip.searchlist.b"},
+ {true, L"tcpip.domain"},
+ {true, L"primary.dns.suffix"},
+ },
+ {"policy.searchlist.a", "policy.searchlist.b"},
+ },
+ {// User-specified SearchList override.
+ {
+ CreateAdapterAddresses(infos),
+ {false},
+ {true, L"tcpip.searchlist.a,tcpip.searchlist.b"},
+ {true, L"tcpip.domain"},
+ {true, L"primary.dns.suffix"},
+ },
+ {"tcpip.searchlist.a", "tcpip.searchlist.b"},
+ },
+ {// Void SearchList. Using tcpip.domain
+ {
+ CreateAdapterAddresses(infos),
+ {true, L",bad.searchlist,parsed.as.empty"},
+ {true, L"tcpip.searchlist,good.but.overridden"},
+ {true, L"tcpip.domain"},
+ {false},
+ },
+ {"tcpip.domain", "connection.suffix"},
+ },
+ {// Void SearchList. Using primary.dns.suffix
+ {
+ CreateAdapterAddresses(infos),
+ {true, L",bad.searchlist,parsed.as.empty"},
+ {true, L"tcpip.searchlist,good.but.overridden"},
+ {true, L"tcpip.domain"},
+ {true, L"primary.dns.suffix"},
+ },
+ {"primary.dns.suffix", "connection.suffix"},
+ },
+ {// Void SearchList. Using tcpip.domain when primary.dns.suffix is empty
+ {
+ CreateAdapterAddresses(infos),
+ {true, L",bad.searchlist,parsed.as.empty"},
+ {true, L"tcpip.searchlist,good.but.overridden"},
+ {true, L"tcpip.domain"},
+ {true, L""},
+ },
+ {"tcpip.domain", "connection.suffix"},
+ },
+ {// Void SearchList. Using tcpip.domain when primary.dns.suffix is NULL
+ {
+ CreateAdapterAddresses(infos),
+ {true, L",bad.searchlist,parsed.as.empty"},
+ {true, L"tcpip.searchlist,good.but.overridden"},
+ {true, L"tcpip.domain"},
+ {true},
+ },
+ {"tcpip.domain", "connection.suffix"},
+ },
+ {// No primary suffix. Devolution does not matter.
+ {
+ CreateAdapterAddresses(infos),
+ {false},
+ {false},
+ {true},
+ {true},
+ {{true, 1}, {true, 2}},
+ },
+ {"connection.suffix"},
+ },
+ {// Devolution enabled by policy, level by dnscache.
+ {
+ CreateAdapterAddresses(infos),
+ {false},
+ {false},
+ {true, L"a.b.c.d.e"},
+ {false},
+ {{true, 1}, {false}}, // policy_devolution: enabled, level
+ {{true, 0}, {true, 3}}, // dnscache_devolution
+ {{true, 0}, {true, 1}}, // tcpip_devolution
+ },
+ {"a.b.c.d.e", "connection.suffix", "b.c.d.e", "c.d.e"},
+ },
+ {// Devolution enabled by dnscache, level by policy.
+ {
+ CreateAdapterAddresses(infos),
+ {false},
+ {false},
+ {true, L"a.b.c.d.e"},
+ {true, L"f.g.i.l.j"},
+ {{false}, {true, 4}},
+ {{true, 1}, {false}},
+ {{true, 0}, {true, 3}},
+ },
+ {"f.g.i.l.j", "connection.suffix", "g.i.l.j"},
+ },
+ {// Devolution enabled by default.
+ {
+ CreateAdapterAddresses(infos),
+ {false},
+ {false},
+ {true, L"a.b.c.d.e"},
+ {false},
+ {{false}, {false}},
+ {{false}, {true, 3}},
+ {{false}, {true, 1}},
+ },
+ {"a.b.c.d.e", "connection.suffix", "b.c.d.e", "c.d.e"},
+ },
+ {// Devolution enabled at level = 2, but nothing to devolve.
+ {
+ CreateAdapterAddresses(infos),
+ {false},
+ {false},
+ {true, L"a.b"},
+ {false},
+ {{false}, {false}},
+ {{false}, {true, 2}},
+ {{false}, {true, 2}},
+ },
+ {"a.b", "connection.suffix"},
+ },
+ {// Devolution disabled when no explicit level.
+ // Windows XP and Vista use a default level = 2, but we don't.
+ {
+ CreateAdapterAddresses(infos),
+ {false},
+ {false},
+ {true, L"a.b.c.d.e"},
+ {false},
+ {{true, 1}, {false}},
+ {{true, 1}, {false}},
+ {{true, 1}, {false}},
+ },
+ {"a.b.c.d.e", "connection.suffix"},
+ },
+ {// Devolution disabled by policy level.
+ {
+ CreateAdapterAddresses(infos),
+ {false},
+ {false},
+ {true, L"a.b.c.d.e"},
+ {false},
+ {{false}, {true, 1}},
+ {{true, 1}, {true, 3}},
+ {{true, 1}, {true, 4}},
+ },
+ {"a.b.c.d.e", "connection.suffix"},
+ },
+ {// Devolution disabled by user setting.
+ {
+ CreateAdapterAddresses(infos),
+ {false},
+ {false},
+ {true, L"a.b.c.d.e"},
+ {false},
+ {{false}, {true, 3}},
+ {{false}, {true, 3}},
+ {{true, 0}, {true, 3}},
+ },
+ {"a.b.c.d.e", "connection.suffix"},
+ },
+ };
for (size_t i = 0; i < arraysize(cases); ++i) {
const TestCase& t = cases[i];
@@ -392,8 +404,7 @@ TEST(DnsConfigServiceWinTest, ConvertSuffixSearch) {
TEST(DnsConfigServiceWinTest, AppendToMultiLabelName) {
AdapterInfo infos[2] = {
- { IF_TYPE_USB, IfOperStatusUp, L"connection.suffix", { "1.0.0.1" } },
- { 0 },
+ {IF_TYPE_USB, IfOperStatusUp, L"connection.suffix", {"1.0.0.1"}}, {0},
};
// The default setting was true pre-Vista.
@@ -403,20 +414,21 @@ TEST(DnsConfigServiceWinTest, AppendToMultiLabelName) {
internal::DnsSystemSettings::RegDword input;
bool expected_output;
} cases[] = {
- { { true, 0 }, false },
- { { true, 1 }, true },
- { { false, 0 }, default_value },
- };
+ {{true, 0}, false}, {{true, 1}, true}, {{false, 0}, default_value},
+ };
for (size_t i = 0; i < arraysize(cases); ++i) {
const TestCase& t = cases[i];
internal::DnsSystemSettings settings = {
- CreateAdapterAddresses(infos),
- { false }, { false }, { false }, { false },
- { { false }, { false } },
- { { false }, { false } },
- { { false }, { false } },
- t.input,
+ CreateAdapterAddresses(infos),
+ {false},
+ {false},
+ {false},
+ {false},
+ {{false}, {false}},
+ {{false}, {false}},
+ {{false}, {false}},
+ t.input,
};
DnsConfig config;
EXPECT_EQ(internal::CONFIG_PARSE_WIN_OK,
@@ -428,8 +440,7 @@ TEST(DnsConfigServiceWinTest, AppendToMultiLabelName) {
// Setting have_name_resolution_policy_table should set unhandled_options.
TEST(DnsConfigServiceWinTest, HaveNRPT) {
AdapterInfo infos[2] = {
- { IF_TYPE_USB, IfOperStatusUp, L"connection.suffix", { "1.0.0.1" } },
- { 0 },
+ {IF_TYPE_USB, IfOperStatusUp, L"connection.suffix", {"1.0.0.1"}}, {0},
};
const struct TestCase {
@@ -437,20 +448,23 @@ TEST(DnsConfigServiceWinTest, HaveNRPT) {
bool unhandled_options;
internal::ConfigParseWinResult result;
} cases[] = {
- { false, false, internal::CONFIG_PARSE_WIN_OK },
- { true, true, internal::CONFIG_PARSE_WIN_UNHANDLED_OPTIONS },
- };
+ {false, false, internal::CONFIG_PARSE_WIN_OK},
+ {true, true, internal::CONFIG_PARSE_WIN_UNHANDLED_OPTIONS},
+ };
for (size_t i = 0; i < arraysize(cases); ++i) {
const TestCase& t = cases[i];
internal::DnsSystemSettings settings = {
- CreateAdapterAddresses(infos),
- { false }, { false }, { false }, { false },
- { { false }, { false } },
- { { false }, { false } },
- { { false }, { false } },
- { false },
- t.have_nrpt,
+ CreateAdapterAddresses(infos),
+ {false},
+ {false},
+ {false},
+ {false},
+ {{false}, {false}},
+ {{false}, {false}},
+ {{false}, {false}},
+ {false},
+ t.have_nrpt,
};
DnsConfig config;
EXPECT_EQ(t.result,
@@ -460,8 +474,6 @@ TEST(DnsConfigServiceWinTest, HaveNRPT) {
}
}
-
} // namespace
} // namespace net
-

Powered by Google App Engine
This is Rietveld 408576698