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

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

Issue 105193002: Replace string16 with base::string16. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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/bookmark_provider.h" 5 #include "chrome/browser/autocomplete/bookmark_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 position_string += ", "; 108 position_string += ", ";
109 position_string += "{" + base::IntToString(i->begin) + ", " + 109 position_string += "{" + base::IntToString(i->begin) + ", " +
110 base::IntToString(i->end) + "}"; 110 base::IntToString(i->end) + "}";
111 } 111 }
112 position_string += "}\n"; 112 position_string += "}\n";
113 return position_string; 113 return position_string;
114 } 114 }
115 115
116 // Return the positions in |matches| as a formatted string for unit test 116 // Return the positions in |matches| as a formatted string for unit test
117 // diagnostic output. 117 // diagnostic output.
118 string16 MatchesAsString16(const ACMatches& matches) { 118 base::string16 MatchesAsString16(const ACMatches& matches) {
119 string16 matches_string; 119 base::string16 matches_string;
120 for (ACMatches::const_iterator i = matches.begin(); i != matches.end(); ++i) { 120 for (ACMatches::const_iterator i = matches.begin(); i != matches.end(); ++i) {
121 matches_string.append(ASCIIToUTF16(" '")); 121 matches_string.append(ASCIIToUTF16(" '"));
122 matches_string.append(i->description); 122 matches_string.append(i->description);
123 matches_string.append(ASCIIToUTF16("'\n")); 123 matches_string.append(ASCIIToUTF16("'\n"));
124 } 124 }
125 return matches_string; 125 return matches_string;
126 } 126 }
127 127
128 // Comparison function for sorting search terms by descending length. 128 // Comparison function for sorting search terms by descending length.
129 bool TestBookmarkPositionsEqual(const TestBookmarkPosition& pos_a, 129 bool TestBookmarkPositionsEqual(const TestBookmarkPosition& pos_a,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // This set uses duplicated and/or overlaps search terms in the title. 236 // This set uses duplicated and/or overlaps search terms in the title.
237 {"frank", 1, {{{0, 5}, {8, 13}, {16, 21}, {0, 0}}}}, 237 {"frank", 1, {{{0, 5}, {8, 13}, {16, 21}, {0, 0}}}},
238 {"frankly", 1, {{{0, 7}, {8, 15}, {0, 0}}}}, 238 {"frankly", 1, {{{0, 7}, {8, 15}, {0, 0}}}},
239 {"frankly frankly", 1, {{{0, 7}, {8, 15}, {0, 0}}}}, 239 {"frankly frankly", 1, {{{0, 7}, {8, 15}, {0, 0}}}},
240 {"foobar foo", 1, {{{0, 6}, {7, 13}, {0, 0}}}}, 240 {"foobar foo", 1, {{{0, 6}, {7, 13}, {0, 0}}}},
241 {"foo foobar", 1, {{{0, 6}, {7, 13}, {0, 0}}}}, 241 {"foo foobar", 1, {{{0, 6}, {7, 13}, {0, 0}}}},
242 }; 242 };
243 243
244 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(query_data); ++i) { 244 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(query_data); ++i) {
245 AutocompleteInput input(ASCIIToUTF16(query_data[i].query), 245 AutocompleteInput input(ASCIIToUTF16(query_data[i].query),
246 string16::npos, string16(), GURL(), 246 base::string16::npos, base::string16(), GURL(),
247 AutocompleteInput::INVALID_SPEC, false, false, 247 AutocompleteInput::INVALID_SPEC, false, false,
248 false, AutocompleteInput::ALL_MATCHES); 248 false, AutocompleteInput::ALL_MATCHES);
249 provider_->Start(input, false); 249 provider_->Start(input, false);
250 const ACMatches& matches(provider_->matches()); 250 const ACMatches& matches(provider_->matches());
251 // Validate number of results is as expected. 251 // Validate number of results is as expected.
252 EXPECT_LE(matches.size(), query_data[i].match_count) 252 EXPECT_LE(matches.size(), query_data[i].match_count)
253 << "One or more of the following matches were unexpected:\n" 253 << "One or more of the following matches were unexpected:\n"
254 << MatchesAsString16(matches) 254 << MatchesAsString16(matches)
255 << "For query '" << query_data[i].query << "'."; 255 << "For query '" << query_data[i].query << "'.";
256 EXPECT_GE(matches.size(), query_data[i].match_count) 256 EXPECT_GE(matches.size(), query_data[i].match_count)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 "burning worms #1"}}, // not boosted 310 "burning worms #1"}}, // not boosted
311 // Ranking of prefix matches with URL boost. Note that a query of 311 // Ranking of prefix matches with URL boost. Note that a query of
312 // "worm burn" will have the same results. 312 // "worm burn" will have the same results.
313 {"burn worm", 3, {"burning worms #2", // boosted 313 {"burn worm", 3, {"burning worms #2", // boosted
314 "worming burns #20", // boosted 314 "worming burns #20", // boosted
315 "burning worms #1"}}, // not boosted but shorter 315 "burning worms #1"}}, // not boosted but shorter
316 }; 316 };
317 317
318 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(query_data); ++i) { 318 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(query_data); ++i) {
319 AutocompleteInput input(ASCIIToUTF16(query_data[i].query), 319 AutocompleteInput input(ASCIIToUTF16(query_data[i].query),
320 string16::npos, string16(), GURL(), 320 base::string16::npos, base::string16(), GURL(),
321 AutocompleteInput::INVALID_SPEC, false, false, 321 AutocompleteInput::INVALID_SPEC, false, false,
322 false, AutocompleteInput::ALL_MATCHES); 322 false, AutocompleteInput::ALL_MATCHES);
323 provider_->Start(input, false); 323 provider_->Start(input, false);
324 const ACMatches& matches(provider_->matches()); 324 const ACMatches& matches(provider_->matches());
325 // Validate number and content of results is as expected. 325 // Validate number and content of results is as expected.
326 for (size_t j = 0; j < std::max(query_data[i].match_count, matches.size()); 326 for (size_t j = 0; j < std::max(query_data[i].match_count, matches.size());
327 ++j) { 327 ++j) {
328 EXPECT_LT(j, query_data[i].match_count) << " Unexpected match '" 328 EXPECT_LT(j, query_data[i].match_count) << " Unexpected match '"
329 << UTF16ToUTF8(matches[j].description) << "' for query: '" 329 << UTF16ToUTF8(matches[j].description) << "' for query: '"
330 << query_data[i].query << "'."; 330 << query_data[i].query << "'.";
331 if (j >= query_data[i].match_count) 331 if (j >= query_data[i].match_count)
332 continue; 332 continue;
333 EXPECT_LT(j, matches.size()) << " Missing match '" 333 EXPECT_LT(j, matches.size()) << " Missing match '"
334 << query_data[i].matches[j] << "' for query: '" 334 << query_data[i].matches[j] << "' for query: '"
335 << query_data[i].query << "'."; 335 << query_data[i].query << "'.";
336 if (j >= matches.size()) 336 if (j >= matches.size())
337 continue; 337 continue;
338 EXPECT_EQ(query_data[i].matches[j], UTF16ToUTF8(matches[j].description)) 338 EXPECT_EQ(query_data[i].matches[j], UTF16ToUTF8(matches[j].description))
339 << " Mismatch at [" << base::IntToString(j) << "] for query '" 339 << " Mismatch at [" << base::IntToString(j) << "] for query '"
340 << query_data[i].query << "'."; 340 << query_data[i].query << "'.";
341 EXPECT_FALSE(matches[j].allowed_to_be_default_match); 341 EXPECT_FALSE(matches[j].allowed_to_be_default_match);
342 } 342 }
343 } 343 }
344 } 344 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/bookmark_provider.cc ('k') | chrome/browser/autocomplete/builtin_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698