| Index: components/url_formatter/url_formatter_unittest.cc
|
| diff --git a/components/url_formatter/url_formatter_unittest.cc b/components/url_formatter/url_formatter_unittest.cc
|
| index 544f55080a4c6eb940f53e55082d9db2e0346762..e768677700d3f93ad061894e71083dd4a22e951f 100644
|
| --- a/components/url_formatter/url_formatter_unittest.cc
|
| +++ b/components/url_formatter/url_formatter_unittest.cc
|
| @@ -1223,6 +1223,49 @@ TEST(UrlFormatterTest, FormatUrlWithOffsets) {
|
| net::UnescapeRule::NORMAL, omit_all_offsets);
|
| }
|
|
|
| +TEST(UrlFormatterTest, StripSubdomains) {
|
| + struct TestCase {
|
| + std::string expected;
|
| + std::string input_host;
|
| + StripSubdomainTypes subdomains_to_strip;
|
| + } cases[] = {
|
| + // Test successful strippings of subdomains.
|
| + {"google.com", "www.google.com", kStripWWW},
|
| + {"google.com", "m.google.com", kStripM},
|
| + {"google.com", "www.google.com", kStripWWW | kStripM},
|
| + {"google.com", "m.google.com", kStripWWW | kStripM},
|
| + {"google.com", "www.m.google.com", kStripWWW | kStripM},
|
| + {"google.com", "m.www.google.com", kStripWWW | kStripM},
|
| +
|
| + // Test partial strippings.
|
| + {"m.google.com", "www.m.google.com", kStripWWW},
|
| + {"www.google.com", "m.www.google.com", kStripM},
|
| + {"en.wikipedia.org", "en.m.wikipedia.org", kStripWWW | kStripM},
|
| + {"foo.google.com", "www.foo.google.com", kStripWWW | kStripM},
|
| + {"foo.google.com", "foo.www.google.com", kStripWWW | kStripM},
|
| +
|
| + // Leave subdomains alone if the flags specify it as such.
|
| + {"www.google.com", "www.google.com", kStripM},
|
| + {"m.google.com", "m.google.com", kStripWWW},
|
| +
|
| + // Leave eTLD+1s (registry and domain) alone.
|
| + {"google.com", "google.com", kStripWWW},
|
| + {"www.com", "www.com", kStripWWW | kStripM},
|
| + {"m.com", "m.com", kStripWWW | kStripM},
|
| + {"mail.google.com", "mail.google.com", kStripWWW | kStripM},
|
| + {"www.co.uk", "www.co.uk", kStripWWW},
|
| + {"www.garden", "www.garden", kStripWWW},
|
| + };
|
| +
|
| + for (TestCase& test_case : cases) {
|
| + EXPECT_EQ(test_case.expected, url_formatter::StripSubdomains(
|
| + GURL("http://" + test_case.input_host),
|
| + test_case.subdomains_to_strip))
|
| + << " input_host = " << test_case.input_host << std::endl
|
| + << " subdomains_to_strip = " << test_case.subdomains_to_strip;
|
| + }
|
| +}
|
| +
|
| } // namespace
|
|
|
| } // namespace url_formatter
|
|
|