| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/omnibox/search_provider.h" | 5 #include "components/omnibox/search_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/test/base/testing_browser_process.h" | 32 #include "chrome/test/base/testing_browser_process.h" |
| 33 #include "chrome/test/base/testing_profile.h" | 33 #include "chrome/test/base/testing_profile.h" |
| 34 #include "components/google/core/browser/google_switches.h" | 34 #include "components/google/core/browser/google_switches.h" |
| 35 #include "components/metrics/proto/omnibox_event.pb.h" | 35 #include "components/metrics/proto/omnibox_event.pb.h" |
| 36 #include "components/omnibox/autocomplete_input.h" | 36 #include "components/omnibox/autocomplete_input.h" |
| 37 #include "components/omnibox/autocomplete_match.h" | 37 #include "components/omnibox/autocomplete_match.h" |
| 38 #include "components/omnibox/autocomplete_provider.h" | 38 #include "components/omnibox/autocomplete_provider.h" |
| 39 #include "components/omnibox/autocomplete_provider_listener.h" | 39 #include "components/omnibox/autocomplete_provider_listener.h" |
| 40 #include "components/omnibox/omnibox_field_trial.h" | 40 #include "components/omnibox/omnibox_field_trial.h" |
| 41 #include "components/omnibox/omnibox_switches.h" | 41 #include "components/omnibox/omnibox_switches.h" |
| 42 #include "components/omnibox/suggestion_answer.h" |
| 42 #include "components/search_engines/search_engine_type.h" | 43 #include "components/search_engines/search_engine_type.h" |
| 43 #include "components/search_engines/search_engines_switches.h" | 44 #include "components/search_engines/search_engines_switches.h" |
| 44 #include "components/search_engines/search_terms_data.h" | 45 #include "components/search_engines/search_terms_data.h" |
| 45 #include "components/search_engines/template_url.h" | 46 #include "components/search_engines/template_url.h" |
| 46 #include "components/search_engines/template_url_service.h" | 47 #include "components/search_engines/template_url_service.h" |
| 47 #include "components/signin/core/browser/signin_manager.h" | 48 #include "components/signin/core/browser/signin_manager.h" |
| 48 #include "components/sync_driver/pref_names.h" | 49 #include "components/sync_driver/pref_names.h" |
| 49 #include "components/variations/entropy_provider.h" | 50 #include "components/variations/entropy_provider.h" |
| 50 #include "components/variations/variations_associated_data.h" | 51 #include "components/variations/variations_associated_data.h" |
| 51 #include "content/public/test/test_browser_thread_bundle.h" | 52 #include "content/public/test/test_browser_thread_bundle.h" |
| (...skipping 3359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3411 | 3412 |
| 3412 // Without scored results, no answers will be retrieved. | 3413 // Without scored results, no answers will be retrieved. |
| 3413 AnswersQueryData answer = provider_->FindAnswersPrefetchData(); | 3414 AnswersQueryData answer = provider_->FindAnswersPrefetchData(); |
| 3414 EXPECT_TRUE(answer.full_query_text.empty()); | 3415 EXPECT_TRUE(answer.full_query_text.empty()); |
| 3415 EXPECT_TRUE(answer.query_type.empty()); | 3416 EXPECT_TRUE(answer.query_type.empty()); |
| 3416 | 3417 |
| 3417 // Inject a scored result, which will trigger answer retrieval. | 3418 // Inject a scored result, which will trigger answer retrieval. |
| 3418 base::string16 query = base::ASCIIToUTF16("weather los angeles"); | 3419 base::string16 query = base::ASCIIToUTF16("weather los angeles"); |
| 3419 SearchSuggestionParser::SuggestResult suggest_result( | 3420 SearchSuggestionParser::SuggestResult suggest_result( |
| 3420 query, AutocompleteMatchType::SEARCH_HISTORY, query, base::string16(), | 3421 query, AutocompleteMatchType::SEARCH_HISTORY, query, base::string16(), |
| 3421 base::string16(), base::string16(), base::string16(), std::string(), | 3422 base::string16(), base::string16(), base::string16(), SuggestionAnswer(), |
| 3422 std::string(), false, 1200, false, false, query); | 3423 std::string(), std::string(), false, 1200, false, false, query); |
| 3423 QueryForInput(ASCIIToUTF16("weather l"), false, false); | 3424 QueryForInput(ASCIIToUTF16("weather l"), false, false); |
| 3424 provider_->transformed_default_history_results_.push_back(suggest_result); | 3425 provider_->transformed_default_history_results_.push_back(suggest_result); |
| 3425 answer = provider_->FindAnswersPrefetchData(); | 3426 answer = provider_->FindAnswersPrefetchData(); |
| 3426 EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"), answer.full_query_text); | 3427 EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"), answer.full_query_text); |
| 3427 EXPECT_EQ(base::ASCIIToUTF16("2334"), answer.query_type); | 3428 EXPECT_EQ(base::ASCIIToUTF16("2334"), answer.query_type); |
| 3428 } | 3429 } |
| 3429 | 3430 |
| 3430 TEST_F(SearchProviderTest, RemoveExtraAnswers) { | 3431 TEST_F(SearchProviderTest, RemoveExtraAnswers) { |
| 3431 ACMatches matches; | 3432 ACMatches matches; |
| 3432 AutocompleteMatch match1, match2, match3, match4, match5; | 3433 AutocompleteMatch match1, match2, match3, match4, match5; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3448 EXPECT_EQ(base::ASCIIToUTF16("42"), matches[0].answer_type); | 3449 EXPECT_EQ(base::ASCIIToUTF16("42"), matches[0].answer_type); |
| 3449 EXPECT_TRUE(matches[1].answer_contents.empty()); | 3450 EXPECT_TRUE(matches[1].answer_contents.empty()); |
| 3450 EXPECT_TRUE(matches[1].answer_type.empty()); | 3451 EXPECT_TRUE(matches[1].answer_type.empty()); |
| 3451 EXPECT_TRUE(matches[2].answer_contents.empty()); | 3452 EXPECT_TRUE(matches[2].answer_contents.empty()); |
| 3452 EXPECT_TRUE(matches[2].answer_type.empty()); | 3453 EXPECT_TRUE(matches[2].answer_type.empty()); |
| 3453 EXPECT_TRUE(matches[3].answer_contents.empty()); | 3454 EXPECT_TRUE(matches[3].answer_contents.empty()); |
| 3454 EXPECT_TRUE(matches[3].answer_type.empty()); | 3455 EXPECT_TRUE(matches[3].answer_type.empty()); |
| 3455 EXPECT_TRUE(matches[4].answer_contents.empty()); | 3456 EXPECT_TRUE(matches[4].answer_contents.empty()); |
| 3456 EXPECT_TRUE(matches[4].answer_type.empty()); | 3457 EXPECT_TRUE(matches[4].answer_type.empty()); |
| 3457 } | 3458 } |
| OLD | NEW |