Chromium Code Reviews| 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 "chrome/browser/autocomplete/search_provider.h" | 5 #include "chrome/browser/autocomplete/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 3230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3241 AutocompleteMatch non_answer_match1; | 3241 AutocompleteMatch non_answer_match1; |
| 3242 non_answer_match1.fill_into_edit = base::ASCIIToUTF16("weather laguna beach"); | 3242 non_answer_match1.fill_into_edit = base::ASCIIToUTF16("weather laguna beach"); |
| 3243 | 3243 |
| 3244 // Test that an answer in the first slot populates the cache. | 3244 // Test that an answer in the first slot populates the cache. |
| 3245 matches.push_back(match1); | 3245 matches.push_back(match1); |
| 3246 matches.push_back(non_answer_match1); | 3246 matches.push_back(non_answer_match1); |
| 3247 result.AppendMatches(matches); | 3247 result.AppendMatches(matches); |
| 3248 provider_->RegisterDisplayedAnswers(result); | 3248 provider_->RegisterDisplayedAnswers(result); |
| 3249 ASSERT_FALSE(provider_->answers_cache_.empty()); | 3249 ASSERT_FALSE(provider_->answers_cache_.empty()); |
| 3250 | 3250 |
| 3251 // Test that DoAnswersQuery retrieves data from cache. | 3251 // Without scored results, no answers will be retrieved. |
| 3252 AutocompleteInput input(base::ASCIIToUTF16("weather l"), | 3252 AnswersQueryData answer = provider_->FindAnswersPrefetchData( |
| 3253 base::string16::npos, base::string16(), GURL(), | 3253 base::ASCIIToUTF16("weather l")); |
| 3254 metrics::OmniboxEventProto::INVALID_SPEC, false, | 3254 EXPECT_TRUE(answer.full_query_text.empty()); |
| 3255 false, true, true, | 3255 EXPECT_TRUE(answer.query_type.empty()); |
| 3256 ChromeAutocompleteSchemeClassifier(&profile_)); | 3256 |
| 3257 provider_->DoAnswersQuery(input); | 3257 // Inject a scored result, which will trigger answer retrieval. |
| 3258 EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"), | 3258 base::string16 query = base::ASCIIToUTF16("weather los angeles"); |
| 3259 provider_->prefetch_data_.full_query_text); | 3259 SearchSuggestionParser::SuggestResult suggest_result( |
| 3260 EXPECT_EQ(base::ASCIIToUTF16("2334"), provider_->prefetch_data_.query_type); | 3260 query, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
|
Mark P
2014/09/05 22:18:17
WHAT_YOU_TYPED seems inappropriate
groby-ooo-7-16
2014/09/10 23:21:38
Done.
| |
| 3261 query, base::string16(), base::string16(), base::string16(), | |
| 3262 base::string16(), std::string(), std::string(), false, 1200, | |
| 3263 true, false, query); | |
|
Mark P
2014/09/05 22:18:17
This true (relevance from server) should be false
groby-ooo-7-16
2014/09/10 23:21:38
Done.
| |
| 3264 provider_->scored_default_history_results_.push_back(suggest_result); | |
| 3265 QueryForInput(ASCIIToUTF16("weather l"), false, false); | |
|
groby-ooo-7-16
2014/08/28 21:36:08
QueryForInput is only called to set up providers_
Mark P
2014/09/05 22:18:17
Nah.
groby-ooo-7-16
2014/09/10 23:21:38
Acknowledged.
| |
| 3266 answer = provider_->FindAnswersPrefetchData(base::ASCIIToUTF16("weather l")); | |
| 3267 EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"), answer.full_query_text); | |
| 3268 EXPECT_EQ(base::ASCIIToUTF16("2334"), answer.query_type); | |
| 3261 } | 3269 } |
| OLD | NEW |