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

Unified Diff: components/url_formatter/url_formatter_unittest.cc

Issue 2966233002: Omnibox UI Experiments: Strip trivial subdomains (Closed)
Patch Set: address one more comment Created 3 years, 5 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
« no previous file with comments | « components/url_formatter/url_formatter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3ba5e361b4fef70c25f413819466d67e2f48365b..49f03f163e13c583daf8c4db457e78e61c65f663 100644
--- a/components/url_formatter/url_formatter_unittest.cc
+++ b/components/url_formatter/url_formatter_unittest.cc
@@ -934,6 +934,56 @@ TEST(UrlFormatterTest, FormatUrl) {
"https://ftp.google.com/",
kFormatUrlOmitHTTP | kFormatUrlExperimentalOmitHTTPS,
net::UnescapeRule::NORMAL, L"https://ftp.google.com/", 8},
+
+ // -------- omit trivial subdomains --------
+ {"omit trivial subdomains - trim www", "http://www.google.com/",
+ kFormatUrlExperimentalOmitTrivialSubdomains, net::UnescapeRule::NORMAL,
+ L"http://google.com/", 7},
+ {"omit trivial subdomains - trim m", "http://m.google.com/",
+ kFormatUrlExperimentalOmitTrivialSubdomains, net::UnescapeRule::NORMAL,
+ L"http://google.com/", 7},
+ {"omit trivial subdomains - trim m and www", "http://m.www.google.com/",
+ kFormatUrlExperimentalOmitTrivialSubdomains, net::UnescapeRule::NORMAL,
+ L"http://google.com/", 7},
+ {"omit trivial subdomains - trim m from middle",
+ "http://en.m.wikipedia.org/",
+ kFormatUrlExperimentalOmitTrivialSubdomains, net::UnescapeRule::NORMAL,
+ L"http://en.wikipedia.org/", 7},
+ {"omit trivial subdomains - don't do blind substring matches for www",
+ "http://wwww.google.com/", kFormatUrlExperimentalOmitTrivialSubdomains,
+ net::UnescapeRule::NORMAL, L"http://wwww.google.com/", 7},
+ {"omit trivial subdomains - don't do blind substring matches for m",
+ "http://foom.google.com/", kFormatUrlExperimentalOmitTrivialSubdomains,
+ net::UnescapeRule::NORMAL, L"http://foom.google.com/", 7},
+ {"omit trivial subdomains - don't crash on multiple delimiters",
+ "http://www...m..foobar...google.com/",
+ kFormatUrlExperimentalOmitTrivialSubdomains, net::UnescapeRule::NORMAL,
+ L"http://...foobar...google.com/", 7},
+
+ {"omit trivial subdomains - sanity check for ordinary subdomains",
+ "http://mail.yahoo.com/", kFormatUrlExperimentalOmitTrivialSubdomains,
+ net::UnescapeRule::NORMAL, L"http://mail.yahoo.com/", 7},
+ {"omit trivial subdomains - sanity check for auth",
+ "http://www:m@google.com/", kFormatUrlExperimentalOmitTrivialSubdomains,
+ net::UnescapeRule::NORMAL, L"http://www:m@google.com/", 13},
+ {"omit trivial subdomains - sanity check for path",
+ "http://google.com/www.m.foobar",
+ kFormatUrlExperimentalOmitTrivialSubdomains, net::UnescapeRule::NORMAL,
+ L"http://google.com/www.m.foobar", 7},
+ {"omit trivial subdomains - sanity check for IDN",
+ "http://www.xn--cy2a840a.m.xn--cy2a840a.com",
+ kFormatUrlExperimentalOmitTrivialSubdomains, net::UnescapeRule::NORMAL,
+ L"http://\x89c6\x9891.\x89c6\x9891.com/", 7},
+
+ {"omit trivial subdomains but leave registry and domain alone - trivial",
+ "http://google.com/", kFormatUrlExperimentalOmitTrivialSubdomains,
+ net::UnescapeRule::NORMAL, L"http://google.com/", 7},
+ {"omit trivial subdomains but leave registry and domain alone - www",
+ "http://www.com/", kFormatUrlExperimentalOmitTrivialSubdomains,
+ net::UnescapeRule::NORMAL, L"http://www.com/", 7},
+ {"omit trivial subdomains but leave registry and domain alone - co.uk",
+ "http://m.co.uk/", kFormatUrlExperimentalOmitTrivialSubdomains,
+ net::UnescapeRule::NORMAL, L"http://m.co.uk/", 7},
};
for (size_t i = 0; i < arraysize(tests); ++i) {
@@ -1313,6 +1363,31 @@ TEST(UrlFormatterTest, FormatUrlWithOffsets) {
CheckAdjustedOffsets("https://u:p@www.google.com/",
kFormatUrlOmitAll | kFormatUrlExperimentalOmitHTTPS,
net::UnescapeRule::NORMAL, omit_https_with_auth_offsets);
+
+ const size_t strip_trivial_subdomains_offsets_1[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, kNpos, kNpos, kNpos, 7, kNpos, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21};
+ CheckAdjustedOffsets("http://www.m.google.com/foo/",
+ kFormatUrlExperimentalOmitTrivialSubdomains,
+ net::UnescapeRule::NORMAL,
+ strip_trivial_subdomains_offsets_1);
+
+ const size_t strip_trivial_subdomains_offsets_2[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, kNpos, 7, 8, 9,
+ 10, kNpos, kNpos, kNpos, 10, 11, 12, 13, 14, 15, 16, 17};
+ CheckAdjustedOffsets(
+ "http://m.en.www.foo.com/", kFormatUrlExperimentalOmitTrivialSubdomains,
+ net::UnescapeRule::NORMAL, strip_trivial_subdomains_offsets_2);
+
+ const size_t strip_trivial_subdomains_from_idn_offsets[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, kNpos, kNpos,
+ kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos,
+ kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 12,
+ 13, 14, 15, 16, 17, 18, 19};
+ CheckAdjustedOffsets("http://www.xn--l8jvb1ey91xtjb.jp/foo/",
+ kFormatUrlExperimentalOmitTrivialSubdomains,
+ net::UnescapeRule::NORMAL,
+ strip_trivial_subdomains_from_idn_offsets);
}
} // namespace
« no previous file with comments | « components/url_formatter/url_formatter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698