Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: chrome/browser/autocomplete/search_provider_unittest.cc

Issue 470313004: [AiS] Use top local result for prefetch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review nit. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/omnibox/search_provider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = provider_->FindAnswersPrefetchData();
3414 base::string16::npos, base::string16(), GURL(), 3414 EXPECT_TRUE(answer.full_query_text.empty());
3415 metrics::OmniboxEventProto::INVALID_SPEC, false, 3415 EXPECT_TRUE(answer.query_type.empty());
3416 false, true, true, 3416
3417 ChromeAutocompleteSchemeClassifier(&profile_)); 3417 // Inject a scored result, which will trigger answer retrieval.
3418 provider_->DoAnswersQuery(input); 3418 base::string16 query = base::ASCIIToUTF16("weather los angeles");
3419 EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"), 3419 SearchSuggestionParser::SuggestResult suggest_result(
3420 provider_->prefetch_data_.full_query_text); 3420 query, AutocompleteMatchType::SEARCH_HISTORY, query, base::string16(),
3421 EXPECT_EQ(base::ASCIIToUTF16("2334"), provider_->prefetch_data_.query_type); 3421 base::string16(), base::string16(), base::string16(), std::string(),
3422 std::string(), false, 1200, false, false, query);
3423 QueryForInput(ASCIIToUTF16("weather l"), false, false);
3424 provider_->transformed_default_history_results_.push_back(suggest_result);
3425 answer = provider_->FindAnswersPrefetchData();
3426 EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"), answer.full_query_text);
3427 EXPECT_EQ(base::ASCIIToUTF16("2334"), answer.query_type);
3422 } 3428 }
OLDNEW
« no previous file with comments | « no previous file | components/omnibox/search_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698