| OLD | NEW |
| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(), false, false, false, | 246 string16::npos, string16(), false, false, false, |
| 247 AutocompleteInput::ALL_MATCHES); | 247 AutocompleteInput::ALL_MATCHES); |
| 248 provider_->Start(input, false); | 248 provider_->Start(input, false); |
| 249 const ACMatches& matches(provider_->matches()); | 249 const ACMatches& matches(provider_->matches()); |
| 250 // Validate number of results is as expected. | 250 // Validate number of results is as expected. |
| 251 EXPECT_LE(matches.size(), query_data[i].match_count) | 251 EXPECT_LE(matches.size(), query_data[i].match_count) |
| 252 << "One or more of the following matches were unexpected:\n" | 252 << "One or more of the following matches were unexpected:\n" |
| 253 << MatchesAsString16(matches) | 253 << MatchesAsString16(matches) |
| 254 << "For query '" << query_data[i].query << "'."; | 254 << "For query '" << query_data[i].query << "'."; |
| 255 EXPECT_GE(matches.size(), query_data[i].match_count) | 255 EXPECT_GE(matches.size(), query_data[i].match_count) |
| 256 << "One or more expected matches are missing. Matches found:\n" | 256 << "One or more expected matches are missing. Matches found:\n" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 "burning worms #1"}}, // not boosted | 309 "burning worms #1"}}, // not boosted |
| 310 // Ranking of prefix matches with URL boost. Note that a query of | 310 // Ranking of prefix matches with URL boost. Note that a query of |
| 311 // "worm burn" will have the same results. | 311 // "worm burn" will have the same results. |
| 312 {"burn worm", 3, {"burning worms #2", // boosted | 312 {"burn worm", 3, {"burning worms #2", // boosted |
| 313 "worming burns #20", // boosted | 313 "worming burns #20", // boosted |
| 314 "burning worms #1"}}, // not boosted but shorter | 314 "burning worms #1"}}, // not boosted but shorter |
| 315 }; | 315 }; |
| 316 | 316 |
| 317 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(query_data); ++i) { | 317 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(query_data); ++i) { |
| 318 AutocompleteInput input(ASCIIToUTF16(query_data[i].query), | 318 AutocompleteInput input(ASCIIToUTF16(query_data[i].query), |
| 319 string16(), false, false, false, | 319 string16::npos, string16(), false, false, false, |
| 320 AutocompleteInput::ALL_MATCHES); | 320 AutocompleteInput::ALL_MATCHES); |
| 321 provider_->Start(input, false); | 321 provider_->Start(input, false); |
| 322 const ACMatches& matches(provider_->matches()); | 322 const ACMatches& matches(provider_->matches()); |
| 323 // Validate number and content of results is as expected. | 323 // Validate number and content of results is as expected. |
| 324 for (size_t j = 0; j < std::max(query_data[i].match_count, matches.size()); | 324 for (size_t j = 0; j < std::max(query_data[i].match_count, matches.size()); |
| 325 ++j) { | 325 ++j) { |
| 326 EXPECT_LT(j, query_data[i].match_count) << " Unexpected match '" | 326 EXPECT_LT(j, query_data[i].match_count) << " Unexpected match '" |
| 327 << UTF16ToUTF8(matches[j].description) << "' for query: '" | 327 << UTF16ToUTF8(matches[j].description) << "' for query: '" |
| 328 << query_data[i].query << "'."; | 328 << query_data[i].query << "'."; |
| 329 if (j >= query_data[i].match_count) | 329 if (j >= query_data[i].match_count) |
| 330 continue; | 330 continue; |
| 331 EXPECT_LT(j, matches.size()) << " Missing match '" | 331 EXPECT_LT(j, matches.size()) << " Missing match '" |
| 332 << query_data[i].matches[j] << "' for query: '" | 332 << query_data[i].matches[j] << "' for query: '" |
| 333 << query_data[i].query << "'."; | 333 << query_data[i].query << "'."; |
| 334 if (j >= matches.size()) | 334 if (j >= matches.size()) |
| 335 continue; | 335 continue; |
| 336 EXPECT_EQ(query_data[i].matches[j], UTF16ToUTF8(matches[j].description)) | 336 EXPECT_EQ(query_data[i].matches[j], UTF16ToUTF8(matches[j].description)) |
| 337 << " Mismatch at [" << base::IntToString(j) << "] for query '" | 337 << " Mismatch at [" << base::IntToString(j) << "] for query '" |
| 338 << query_data[i].query << "'."; | 338 << query_data[i].query << "'."; |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 } | 341 } |
| OLD | NEW |