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

Side by Side 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: minor improvements 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 unified diff | Download patch
« no previous file with comments | « components/omnibox/autocomplete_match.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/omnibox/autocomplete_match.h" 5 #include "components/omnibox/autocomplete_match.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 TEST(AutocompleteMatchTest, MoreRelevant) { 10 TEST(AutocompleteMatchTest, MoreRelevant) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 NULL, 0, false, AutocompleteMatchType::URL_WHAT_YOU_TYPED)); 120 NULL, 0, false, AutocompleteMatchType::URL_WHAT_YOU_TYPED));
121 m.duplicate_matches.push_back(AutocompleteMatch( 121 m.duplicate_matches.push_back(AutocompleteMatch(
122 NULL, 0, false, AutocompleteMatchType::URL_WHAT_YOU_TYPED)); 122 NULL, 0, false, AutocompleteMatchType::URL_WHAT_YOU_TYPED));
123 EXPECT_FALSE(m.SupportsDeletion()); 123 EXPECT_FALSE(m.SupportsDeletion());
124 124
125 // A non-deletable match, with at least one deletable duplicate. 125 // A non-deletable match, with at least one deletable duplicate.
126 m.duplicate_matches.push_back(AutocompleteMatch( 126 m.duplicate_matches.push_back(AutocompleteMatch(
127 NULL, 0, true, AutocompleteMatchType::URL_WHAT_YOU_TYPED)); 127 NULL, 0, true, AutocompleteMatchType::URL_WHAT_YOU_TYPED));
128 EXPECT_TRUE(m.SupportsDeletion()); 128 EXPECT_TRUE(m.SupportsDeletion());
129 } 129 }
130
131 TEST(AutocompleteMatchTest, Duplicates) {
132 struct DuplicateCases {
133 std::string url1;
134 std::string url2;
135 bool expected_duplicate;
136 } cases[] = {
137 { "http://www.google.com/", "https://www.google.com/", true },
138 { "http://www.google.com/", "http://www.google.com", true },
139 { "http://google.com/", "http://www.google.com/", true },
140 { "http://www.google.com/", "HTTP://www.GOOGLE.com/", true },
141 { "http://www.google.com/1", "http://www.google.com/1/", true },
142 { "http://www.google.com/", "http://www.google.com", true },
143 { "https://www.google.com/", "http://google.com", true },
144 { "http://www.google.com/", "wss://www.google.com/", false },
145 { "http://www.google.com/", "http://www.google.com/1", false },
146 { "http://www.google.com/", "http://www.goo.com/", false },
147 { "http://www.google.com/", "http://w2.google.com/", false },
148 { "http://www.google.com/", "http://m.google.com/", false },
149 { "http://www.google.com/", "http://www.google.com/?foo", false },
150 };
151
152 for (size_t i = 0; i < arraysize(cases); ++i) {
153 SCOPED_TRACE("url1=" + cases[i].url1 + " url2=" + cases[i].url2);
154 AutocompleteMatch m1(NULL, 100, false,
155 AutocompleteMatchType::URL_WHAT_YOU_TYPED);
156 m1.destination_url = GURL(cases[i].url1);
157 m1.ComputeStrippedDestinationURL(NULL);
158 AutocompleteMatch m2(NULL, 100, false,
159 AutocompleteMatchType::URL_WHAT_YOU_TYPED);
160 m2.destination_url = GURL(cases[i].url2);
161 m2.ComputeStrippedDestinationURL(NULL);
162 EXPECT_EQ(cases[i].expected_duplicate,
163 AutocompleteMatch::DestinationsEqual(m1, m2));
164 }
165 }
OLDNEW
« no previous file with comments | « components/omnibox/autocomplete_match.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698