OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/history_url_provider.h" | 5 #include "chrome/browser/autocomplete/history_url_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 const std::string* expected_urls, | 225 const std::string* expected_urls, |
226 size_t num_results) { | 226 size_t num_results) { |
227 AutocompleteInput input(text, desired_tld, prevent_inline_autocomplete, | 227 AutocompleteInput input(text, desired_tld, prevent_inline_autocomplete, |
228 false, true, AutocompleteInput::ALL_MATCHES); | 228 false, true, AutocompleteInput::ALL_MATCHES); |
229 autocomplete_->Start(input, false); | 229 autocomplete_->Start(input, false); |
230 if (!autocomplete_->done()) | 230 if (!autocomplete_->done()) |
231 MessageLoop::current()->Run(); | 231 MessageLoop::current()->Run(); |
232 | 232 |
233 matches_ = autocomplete_->matches(); | 233 matches_ = autocomplete_->matches(); |
234 if (sort_matches_) { | 234 if (sort_matches_) { |
235 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) | |
236 i->ComputeStrippedDestinationURL(); | |
237 std::sort(matches_.begin(), matches_.end(), | 235 std::sort(matches_.begin(), matches_.end(), |
238 &AutocompleteMatch::DestinationSortFunc); | 236 &AutocompleteMatch::DestinationSortFunc); |
239 matches_.erase(std::unique(matches_.begin(), matches_.end(), | 237 matches_.erase(std::unique(matches_.begin(), matches_.end(), |
240 &AutocompleteMatch::DestinationsEqual), | 238 &AutocompleteMatch::DestinationsEqual), |
241 matches_.end()); | 239 matches_.end()); |
242 std::sort(matches_.begin(), matches_.end(), | 240 std::sort(matches_.begin(), matches_.end(), |
243 &AutocompleteMatch::MoreRelevant); | 241 &AutocompleteMatch::MoreRelevant); |
244 } | 242 } |
245 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text | 243 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text |
246 << "\nTLD: \"" << desired_tld << "\""; | 244 << "\nTLD: \"" << desired_tld << "\""; |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 "\\@st" | 660 "\\@st" |
663 }; | 661 }; |
664 for (size_t i = 0; i < arraysize(test_cases); ++i) { | 662 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
665 AutocompleteInput input(ASCIIToUTF16(test_cases[i]), string16(), false, | 663 AutocompleteInput input(ASCIIToUTF16(test_cases[i]), string16(), false, |
666 false, true, AutocompleteInput::ALL_MATCHES); | 664 false, true, AutocompleteInput::ALL_MATCHES); |
667 autocomplete_->Start(input, false); | 665 autocomplete_->Start(input, false); |
668 if (!autocomplete_->done()) | 666 if (!autocomplete_->done()) |
669 MessageLoop::current()->Run(); | 667 MessageLoop::current()->Run(); |
670 } | 668 } |
671 } | 669 } |
OLD | NEW |