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/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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 metrics::OmniboxEventProto::INVALID_SPEC, | 287 metrics::OmniboxEventProto::INVALID_SPEC, |
288 prevent_inline_autocomplete, false, true, true, | 288 prevent_inline_autocomplete, false, true, true, |
289 ChromeAutocompleteSchemeClassifier(profile_.get())); | 289 ChromeAutocompleteSchemeClassifier(profile_.get())); |
290 *identified_input_type = input.type(); | 290 *identified_input_type = input.type(); |
291 autocomplete_->Start(input, false); | 291 autocomplete_->Start(input, false); |
292 if (!autocomplete_->done()) | 292 if (!autocomplete_->done()) |
293 base::MessageLoop::current()->Run(); | 293 base::MessageLoop::current()->Run(); |
294 | 294 |
295 matches_ = autocomplete_->matches(); | 295 matches_ = autocomplete_->matches(); |
296 if (sort_matches_) { | 296 if (sort_matches_) { |
| 297 TemplateURLService* service = |
| 298 TemplateURLServiceFactory::GetForProfile(profile_.get()); |
297 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) | 299 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) |
298 i->ComputeStrippedDestinationURL(profile_.get()); | 300 i->ComputeStrippedDestinationURL(service); |
299 AutocompleteResult::DedupMatchesByDestination( | 301 AutocompleteResult::DedupMatchesByDestination( |
300 input.current_page_classification(), false, &matches_); | 302 input.current_page_classification(), false, &matches_); |
301 std::sort(matches_.begin(), matches_.end(), | 303 std::sort(matches_.begin(), matches_.end(), |
302 &AutocompleteMatch::MoreRelevant); | 304 &AutocompleteMatch::MoreRelevant); |
303 } | 305 } |
304 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text | 306 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text |
305 << "\nTLD: \"" << desired_tld << "\""; | 307 << "\nTLD: \"" << desired_tld << "\""; |
306 for (size_t i = 0; i < num_results; ++i) { | 308 for (size_t i = 0; i < num_results; ++i) { |
307 EXPECT_EQ(expected_urls[i].url, matches_[i].destination_url.spec()); | 309 EXPECT_EQ(expected_urls[i].url, matches_[i].destination_url.spec()); |
308 EXPECT_EQ(expected_urls[i].allowed_to_be_default_match, | 310 EXPECT_EQ(expected_urls[i].allowed_to_be_default_match, |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 autocomplete_->scoring_params_.experimental_scoring_enabled = true; | 1022 autocomplete_->scoring_params_.experimental_scoring_enabled = true; |
1021 ASSERT_NO_FATAL_FAILURE( | 1023 ASSERT_NO_FATAL_FAILURE( |
1022 RunTest(ASCIIToUTF16(test_cases[i].input), | 1024 RunTest(ASCIIToUTF16(test_cases[i].input), |
1023 base::string16(), false, output, max_matches)); | 1025 base::string16(), false, output, max_matches)); |
1024 for (int j = 0; j < max_matches; ++j) { | 1026 for (int j = 0; j < max_matches; ++j) { |
1025 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance, | 1027 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance, |
1026 matches_[j].relevance); | 1028 matches_[j].relevance); |
1027 } | 1029 } |
1028 } | 1030 } |
1029 } | 1031 } |
OLD | NEW |