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 3391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3402 AutocompleteMatch non_answer_match1; | 3402 AutocompleteMatch non_answer_match1; |
3403 non_answer_match1.fill_into_edit = base::ASCIIToUTF16("weather laguna beach"); | 3403 non_answer_match1.fill_into_edit = base::ASCIIToUTF16("weather laguna beach"); |
3404 | 3404 |
3405 // Test that an answer in the first slot populates the cache. | 3405 // Test that an answer in the first slot populates the cache. |
3406 matches.push_back(match1); | 3406 matches.push_back(match1); |
3407 matches.push_back(non_answer_match1); | 3407 matches.push_back(non_answer_match1); |
3408 result.AppendMatches(matches); | 3408 result.AppendMatches(matches); |
3409 provider_->RegisterDisplayedAnswers(result); | 3409 provider_->RegisterDisplayedAnswers(result); |
3410 ASSERT_FALSE(provider_->answers_cache_.empty()); | 3410 ASSERT_FALSE(provider_->answers_cache_.empty()); |
3411 | 3411 |
3412 // Test that DoAnswersQuery retrieves data from cache. | 3412 // Without scored results, no answers will be retrieved. |
3413 AutocompleteInput input(base::ASCIIToUTF16("weather l"), | 3413 AnswersQueryData answer = |
3414 base::string16::npos, base::string16(), GURL(), | 3414 provider_->FindAnswersPrefetchData(base::ASCIIToUTF16("weather l")); |
3415 metrics::OmniboxEventProto::INVALID_SPEC, false, | 3415 EXPECT_TRUE(answer.full_query_text.empty()); |
3416 false, true, true, | 3416 EXPECT_TRUE(answer.query_type.empty()); |
3417 ChromeAutocompleteSchemeClassifier(&profile_)); | 3417 |
3418 provider_->DoAnswersQuery(input); | 3418 // Inject a scored result, which will trigger answer retrieval. |
3419 EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"), | 3419 base::string16 query = base::ASCIIToUTF16("weather los angeles"); |
3420 provider_->prefetch_data_.full_query_text); | 3420 SearchSuggestionParser::SuggestResult suggest_result( |
3421 EXPECT_EQ(base::ASCIIToUTF16("2334"), provider_->prefetch_data_.query_type); | 3421 query, AutocompleteMatchType::SEARCH_HISTORY, query, base::string16(), |
3422 base::string16(), base::string16(), base::string16(), std::string(), | |
3423 std::string(), false, 1200, true, false, query); | |
Mark P
2014/09/16 22:24:55
Not done. It looks like the third to last paramet
groby-ooo-7-16
2014/09/18 23:27:24
Done.
| |
3424 QueryForInput(ASCIIToUTF16("weather l"), false, false); | |
3425 provider_->transformed_default_history_results_.push_back(suggest_result); | |
3426 answer = provider_->FindAnswersPrefetchData(base::ASCIIToUTF16("weather l")); | |
3427 EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"), answer.full_query_text); | |
3428 EXPECT_EQ(base::ASCIIToUTF16("2334"), answer.query_type); | |
3422 } | 3429 } |
OLD | NEW |