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

Unified 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: Use top suggestion to retrieve answer. Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/search_provider_unittest.cc
diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc
index 3afcbacb834868d33ed099601404c9d7f68e346d..002ae29015b1216d4ad729754243ec4a01edac78 100644
--- a/chrome/browser/autocomplete/search_provider_unittest.cc
+++ b/chrome/browser/autocomplete/search_provider_unittest.cc
@@ -3248,14 +3248,22 @@ TEST_F(SearchProviderTest, AnswersCache) {
provider_->RegisterDisplayedAnswers(result);
ASSERT_FALSE(provider_->answers_cache_.empty());
- // Test that DoAnswersQuery retrieves data from cache.
- AutocompleteInput input(base::ASCIIToUTF16("weather l"),
- base::string16::npos, base::string16(), GURL(),
- metrics::OmniboxEventProto::INVALID_SPEC, false,
- false, true, true,
- ChromeAutocompleteSchemeClassifier(&profile_));
- provider_->DoAnswersQuery(input);
- EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"),
- provider_->prefetch_data_.full_query_text);
- EXPECT_EQ(base::ASCIIToUTF16("2334"), provider_->prefetch_data_.query_type);
+ // Without scored results, no answers will be retrieved.
+ AnswersQueryData answer = provider_->FindAnswersPrefetchData(
+ base::ASCIIToUTF16("weather l"));
+ EXPECT_TRUE(answer.full_query_text.empty());
+ EXPECT_TRUE(answer.query_type.empty());
+
+ // Inject a scored result, which will trigger answer retrieval.
+ base::string16 query = base::ASCIIToUTF16("weather los angeles");
+ SearchSuggestionParser::SuggestResult suggest_result(
+ 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.
+ query, base::string16(), base::string16(), base::string16(),
+ base::string16(), std::string(), std::string(), false, 1200,
+ 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.
+ provider_->scored_default_history_results_.push_back(suggest_result);
+ 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.
+ answer = provider_->FindAnswersPrefetchData(base::ASCIIToUTF16("weather l"));
+ EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"), answer.full_query_text);
+ EXPECT_EQ(base::ASCIIToUTF16("2334"), answer.query_type);
}

Powered by Google App Engine
This is Rietveld 408576698