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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/strings/string_split.h" | |
11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 15 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
15 #include "chrome/browser/autocomplete/history_quick_provider.h" | 16 #include "chrome/browser/autocomplete/history_quick_provider.h" |
16 #include "chrome/browser/history/history_service_factory.h" | 17 #include "chrome/browser/history/history_service_factory.h" |
17 #include "chrome/browser/search_engines/chrome_template_url_service_client.h" | 18 #include "chrome/browser/search_engines/chrome_template_url_service_client.h" |
18 #include "chrome/browser/search_engines/template_url_service_factory.h" | 19 #include "chrome/browser/search_engines/template_url_service_factory.h" |
19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
20 #include "chrome/test/base/testing_browser_process.h" | 21 #include "chrome/test/base/testing_browser_process.h" |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 ChromeAutocompleteSchemeClassifier(profile_.get())); | 311 ChromeAutocompleteSchemeClassifier(profile_.get())); |
311 *identified_input_type = input.type(); | 312 *identified_input_type = input.type(); |
312 autocomplete_->Start(input, false, false); | 313 autocomplete_->Start(input, false, false); |
313 if (!autocomplete_->done()) | 314 if (!autocomplete_->done()) |
314 base::MessageLoop::current()->Run(); | 315 base::MessageLoop::current()->Run(); |
315 | 316 |
316 matches_ = autocomplete_->matches(); | 317 matches_ = autocomplete_->matches(); |
317 if (sort_matches_) { | 318 if (sort_matches_) { |
318 TemplateURLService* service = | 319 TemplateURLService* service = |
319 TemplateURLServiceFactory::GetForProfile(profile_.get()); | 320 TemplateURLServiceFactory::GetForProfile(profile_.get()); |
320 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) | 321 std::vector<base::string16> words; |
321 i->ComputeStrippedDestinationURL(service); | 322 base::SplitString(input.text(), ' ', &words); |
323 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) { | |
Peter Kasting
2015/06/06 01:31:23
Nit: No {}
Mark P
2015/06/09 19:29:38
Done.
| |
324 i->ComputeStrippedDestinationURL(words, service); | |
325 } | |
322 AutocompleteResult::DedupMatchesByDestination( | 326 AutocompleteResult::DedupMatchesByDestination( |
323 input.current_page_classification(), false, &matches_); | 327 input.current_page_classification(), false, &matches_); |
324 std::sort(matches_.begin(), matches_.end(), | 328 std::sort(matches_.begin(), matches_.end(), |
325 &AutocompleteMatch::MoreRelevant); | 329 &AutocompleteMatch::MoreRelevant); |
326 } | 330 } |
327 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text | 331 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text |
328 << "\nTLD: \"" << desired_tld << "\""; | 332 << "\nTLD: \"" << desired_tld << "\""; |
329 for (size_t i = 0; i < num_results; ++i) { | 333 for (size_t i = 0; i < num_results; ++i) { |
330 EXPECT_EQ(expected_urls[i].url, matches_[i].destination_url.spec()); | 334 EXPECT_EQ(expected_urls[i].url, matches_[i].destination_url.spec()); |
331 EXPECT_EQ(expected_urls[i].allowed_to_be_default_match, | 335 EXPECT_EQ(expected_urls[i].allowed_to_be_default_match, |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1059 // Test the experiment (scoring enabled). | 1063 // Test the experiment (scoring enabled). |
1060 autocomplete_->scoring_params_.experimental_scoring_enabled = true; | 1064 autocomplete_->scoring_params_.experimental_scoring_enabled = true; |
1061 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input), | 1065 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input), |
1062 std::string(), false, output, max_matches)); | 1066 std::string(), false, output, max_matches)); |
1063 for (int j = 0; j < max_matches; ++j) { | 1067 for (int j = 0; j < max_matches; ++j) { |
1064 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance, | 1068 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance, |
1065 matches_[j].relevance); | 1069 matches_[j].relevance); |
1066 } | 1070 } |
1067 } | 1071 } |
1068 } | 1072 } |
OLD | NEW |