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()); | |
299 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) | 297 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) |
300 i->ComputeStrippedDestinationURL(service); | 298 i->ComputeStrippedDestinationURL(profile_.get()); |
301 AutocompleteResult::DedupMatchesByDestination( | 299 AutocompleteResult::DedupMatchesByDestination( |
302 input.current_page_classification(), false, &matches_); | 300 input.current_page_classification(), false, &matches_); |
303 std::sort(matches_.begin(), matches_.end(), | 301 std::sort(matches_.begin(), matches_.end(), |
304 &AutocompleteMatch::MoreRelevant); | 302 &AutocompleteMatch::MoreRelevant); |
305 } | 303 } |
306 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text | 304 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text |
307 << "\nTLD: \"" << desired_tld << "\""; | 305 << "\nTLD: \"" << desired_tld << "\""; |
308 for (size_t i = 0; i < num_results; ++i) { | 306 for (size_t i = 0; i < num_results; ++i) { |
309 EXPECT_EQ(expected_urls[i].url, matches_[i].destination_url.spec()); | 307 EXPECT_EQ(expected_urls[i].url, matches_[i].destination_url.spec()); |
310 EXPECT_EQ(expected_urls[i].allowed_to_be_default_match, | 308 EXPECT_EQ(expected_urls[i].allowed_to_be_default_match, |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 autocomplete_->scoring_params_.experimental_scoring_enabled = true; | 1020 autocomplete_->scoring_params_.experimental_scoring_enabled = true; |
1023 ASSERT_NO_FATAL_FAILURE( | 1021 ASSERT_NO_FATAL_FAILURE( |
1024 RunTest(ASCIIToUTF16(test_cases[i].input), | 1022 RunTest(ASCIIToUTF16(test_cases[i].input), |
1025 base::string16(), false, output, max_matches)); | 1023 base::string16(), false, output, max_matches)); |
1026 for (int j = 0; j < max_matches; ++j) { | 1024 for (int j = 0; j < max_matches; ++j) { |
1027 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance, | 1025 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance, |
1028 matches_[j].relevance); | 1026 matches_[j].relevance); |
1029 } | 1027 } |
1030 } | 1028 } |
1031 } | 1029 } |
OLD | NEW |