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

Unified Diff: components/omnibox/autocomplete_match_unittest.cc

Issue 1169173005: Omnibox - Mark As Duplicates URLs that only differ by a trailing slash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: peter's optimizations Created 5 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 side-by-side diff with in-line comments
Download patch
Index: components/omnibox/autocomplete_match_unittest.cc
diff --git a/components/omnibox/autocomplete_match_unittest.cc b/components/omnibox/autocomplete_match_unittest.cc
index 2fba94c1dfe8189fc7239ea53be8d8975e78fe11..bcc26e23e43268799f9bf0931dd889eb676bda50 100644
--- a/components/omnibox/autocomplete_match_unittest.cc
+++ b/components/omnibox/autocomplete_match_unittest.cc
@@ -127,3 +127,39 @@ TEST(AutocompleteMatchTest, SupportsDeletion) {
NULL, 0, true, AutocompleteMatchType::URL_WHAT_YOU_TYPED));
EXPECT_TRUE(m.SupportsDeletion());
}
+
+TEST(AutocompleteMatchTest, Duplicates) {
+ struct DuplicateCases {
+ std::string url1;
+ std::string url2;
+ bool expected_duplicate;
+ } cases[] = {
+ { "http://www.google.com/", "https://www.google.com/", true },
+ { "http://www.google.com/", "http://www.google.com", true },
+ { "http://google.com/", "http://www.google.com/", true },
+ { "http://www.google.com/", "HTTP://www.GOOGLE.com/", true },
+ { "http://www.google.com/1", "http://www.google.com/1/", true },
Peter Kasting 2015/06/12 19:30:36 Nit: How come there are two spaces between url1 an
Mark P 2015/06/12 19:57:57 Fixed extra space (in whole vertical column).
+ { "http://www.google.com/", "http://www.google.com", true },
+ { "https://www.google.com/", "http://google.com", true },
+ { "http://www.google.com/", "wss://www.google.com/", false },
+ { "http://www.google.com/", "http://www.google.com/1", false },
+ { "http://www.google.com/", "http://www.goo.com/", false },
+ { "http://www.google.com/", "http://w2.google.com/", false },
+ { "http://www.google.com/", "http://m.google.com/", false },
+ { "http://www.google.com/", "http://www.google.com/?foo", false },
+ };
+
+ for (size_t i = 0; i < arraysize(cases); ++i) {
+ SCOPED_TRACE("url1=" + cases[i].url1 + " url2=" + cases[i].url2);
+ AutocompleteMatch m1(NULL, 100, false,
+ AutocompleteMatchType::URL_WHAT_YOU_TYPED);
+ m1.destination_url = GURL(cases[i].url1);
+ m1.ComputeStrippedDestinationURL(NULL);
+ AutocompleteMatch m2(NULL, 100, false,
+ AutocompleteMatchType::URL_WHAT_YOU_TYPED);
+ m2.destination_url = GURL(cases[i].url2);
+ m2.ComputeStrippedDestinationURL(NULL);
+ EXPECT_EQ(cases[i].expected_duplicate,
+ AutocompleteMatch::DestinationsEqual(m1, m2));
+ }
+}
« components/omnibox/autocomplete_match.cc ('K') | « components/omnibox/autocomplete_match.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698