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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_result_unittest.cc

Issue 109013006: Update some uses of UTF conversions in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 12 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/autocomplete/autocomplete_result.h" 5 #include "chrome/browser/autocomplete/autocomplete_result.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 EXPECT_EQ(expected_match.relevance, match.relevance) << i; 161 EXPECT_EQ(expected_match.relevance, match.relevance) << i;
162 EXPECT_EQ(expected_match.destination_url.spec(), 162 EXPECT_EQ(expected_match.destination_url.spec(),
163 match.destination_url.spec()) << i; 163 match.destination_url.spec()) << i;
164 } 164 }
165 } 165 }
166 166
167 void AutocompleteResultTest::RunCopyOldMatchesTest( 167 void AutocompleteResultTest::RunCopyOldMatchesTest(
168 const TestData* last, size_t last_size, 168 const TestData* last, size_t last_size,
169 const TestData* current, size_t current_size, 169 const TestData* current, size_t current_size,
170 const TestData* expected, size_t expected_size) { 170 const TestData* expected, size_t expected_size) {
171 AutocompleteInput input(ASCIIToUTF16("a"), base::string16::npos, 171 AutocompleteInput input(base::ASCIIToUTF16("a"), base::string16::npos,
172 base::string16(), GURL(), 172 base::string16(), GURL(),
173 AutocompleteInput::INVALID_SPEC, false, false, false, 173 AutocompleteInput::INVALID_SPEC, false, false, false,
174 AutocompleteInput::ALL_MATCHES); 174 AutocompleteInput::ALL_MATCHES);
175 175
176 ACMatches last_matches; 176 ACMatches last_matches;
177 PopulateAutocompleteMatches(last, last_size, &last_matches); 177 PopulateAutocompleteMatches(last, last_size, &last_matches);
178 AutocompleteResult last_result; 178 AutocompleteResult last_result;
179 last_result.AppendMatches(last_matches); 179 last_result.AppendMatches(last_matches);
180 last_result.SortAndCull(input, test_util_.profile()); 180 last_result.SortAndCull(input, test_util_.profile());
181 181
(...skipping 15 matching lines...) Expand all
197 // Swap with empty shouldn't do anything interesting. 197 // Swap with empty shouldn't do anything interesting.
198 r1.Swap(&r2); 198 r1.Swap(&r2);
199 EXPECT_EQ(r1.end(), r1.default_match()); 199 EXPECT_EQ(r1.end(), r1.default_match());
200 EXPECT_EQ(r2.end(), r2.default_match()); 200 EXPECT_EQ(r2.end(), r2.default_match());
201 201
202 // Swap with a single match. 202 // Swap with a single match.
203 ACMatches matches; 203 ACMatches matches;
204 AutocompleteMatch match; 204 AutocompleteMatch match;
205 match.relevance = 1; 205 match.relevance = 1;
206 match.allowed_to_be_default_match = true; 206 match.allowed_to_be_default_match = true;
207 AutocompleteInput input(ASCIIToUTF16("a"), base::string16::npos, 207 AutocompleteInput input(base::ASCIIToUTF16("a"), base::string16::npos,
208 base::string16(), GURL(), 208 base::string16(), GURL(),
209 AutocompleteInput::INVALID_SPEC, false, false, false, 209 AutocompleteInput::INVALID_SPEC, false, false, false,
210 AutocompleteInput::ALL_MATCHES); 210 AutocompleteInput::ALL_MATCHES);
211 matches.push_back(match); 211 matches.push_back(match);
212 r1.AppendMatches(matches); 212 r1.AppendMatches(matches);
213 r1.SortAndCull(input, test_util_.profile()); 213 r1.SortAndCull(input, test_util_.profile());
214 EXPECT_EQ(r1.begin(), r1.default_match()); 214 EXPECT_EQ(r1.begin(), r1.default_match());
215 EXPECT_EQ("http://a/", r1.alternate_nav_url().spec()); 215 EXPECT_EQ("http://a/", r1.alternate_nav_url().spec());
216 r1.Swap(&r2); 216 r1.Swap(&r2);
217 EXPECT_TRUE(r1.empty()); 217 EXPECT_TRUE(r1.empty());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 EXPECT_EQ(1200, result.match_at(1)->relevance); 303 EXPECT_EQ(1200, result.match_at(1)->relevance);
304 EXPECT_TRUE(result.match_at(2)->destination_url.is_empty()); 304 EXPECT_TRUE(result.match_at(2)->destination_url.is_empty());
305 EXPECT_EQ(1100, result.match_at(2)->relevance); 305 EXPECT_EQ(1100, result.match_at(2)->relevance);
306 EXPECT_EQ("http://b/", result.match_at(3)->destination_url.spec()); 306 EXPECT_EQ("http://b/", result.match_at(3)->destination_url.spec());
307 EXPECT_EQ(1000, result.match_at(3)->relevance); 307 EXPECT_EQ(1000, result.match_at(3)->relevance);
308 } 308 }
309 309
310 TEST_F(AutocompleteResultTest, SortAndCullDuplicateSearchURLs) { 310 TEST_F(AutocompleteResultTest, SortAndCullDuplicateSearchURLs) {
311 // Register a template URL that corresponds to 'foo' search engine. 311 // Register a template URL that corresponds to 'foo' search engine.
312 TemplateURLData url_data; 312 TemplateURLData url_data;
313 url_data.short_name = ASCIIToUTF16("unittest"); 313 url_data.short_name = base::ASCIIToUTF16("unittest");
314 url_data.SetKeyword(ASCIIToUTF16("foo")); 314 url_data.SetKeyword(base::ASCIIToUTF16("foo"));
315 url_data.SetURL("http://www.foo.com/s?q={searchTerms}"); 315 url_data.SetURL("http://www.foo.com/s?q={searchTerms}");
316 test_util_.model()->Add(new TemplateURL(test_util_.profile(), url_data)); 316 test_util_.model()->Add(new TemplateURL(test_util_.profile(), url_data));
317 317
318 TestData data[] = { 318 TestData data[] = {
319 { 0, 0, 1300 }, 319 { 0, 0, 1300 },
320 { 1, 0, 1200 }, 320 { 1, 0, 1200 },
321 { 2, 0, 1100 }, 321 { 2, 0, 1100 },
322 { 3, 0, 1000 }, 322 { 3, 0, 1000 },
323 { 4, 1, 900 }, 323 { 4, 1, 900 },
324 }; 324 };
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 result.Reset(); 578 result.Reset();
579 matches.clear(); 579 matches.clear();
580 580
581 // Case 5: Multiple verbatim matches found in AutocompleteResult. 581 // Case 5: Multiple verbatim matches found in AutocompleteResult.
582 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches, 582 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches,
583 arraysize(kVerbatimMatches), 583 arraysize(kVerbatimMatches),
584 &matches); 584 &matches);
585 result.AppendMatches(matches); 585 result.AppendMatches(matches);
586 EXPECT_FALSE(result.ShouldHideTopMatch()); 586 EXPECT_FALSE(result.ShouldHideTopMatch());
587 } 587 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_result.cc ('k') | chrome/browser/autocomplete/bookmark_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698