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

Unified Diff: components/omnibox/base_search_provider_unittest.cc

Issue 669573005: Add a class to parse answer json. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix case on "copyright" 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/omnibox/base_search_provider.cc ('k') | components/omnibox/search_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/omnibox/base_search_provider_unittest.cc
diff --git a/components/omnibox/base_search_provider_unittest.cc b/components/omnibox/base_search_provider_unittest.cc
index 42a9f1819719fce646e8bb54c0a9ca22e6b1dbbb..d5a2f6734a75ca84abc063611a46568cdb36f8f0 100644
--- a/components/omnibox/base_search_provider_unittest.cc
+++ b/components/omnibox/base_search_provider_unittest.cc
@@ -11,6 +11,7 @@
#include "components/omnibox/autocomplete_provider_client.h"
#include "components/omnibox/autocomplete_scheme_classifier.h"
#include "components/omnibox/search_suggestion_parser.h"
+#include "components/omnibox/suggestion_answer.h"
#include "components/search_engines/search_terms_data.h"
#include "components/search_engines/template_url_service.h"
#include "components/search_engines/template_url_service_client.h"
@@ -124,6 +125,8 @@ TEST_F(BaseSearchProviderTest, PreserveAnswersWhenDeduplicating) {
base::string16 query = base::ASCIIToUTF16("weather los angeles");
base::string16 answer_contents = base::ASCIIToUTF16("some answer content");
base::string16 answer_type = base::ASCIIToUTF16("2334");
+ scoped_ptr<SuggestionAnswer> answer(new SuggestionAnswer());
+ answer->set_type(2334);
EXPECT_CALL(*provider_, GetInput(_))
.WillRepeatedly(Return(AutocompleteInput()));
@@ -132,16 +135,17 @@ TEST_F(BaseSearchProviderTest, PreserveAnswersWhenDeduplicating) {
SearchSuggestionParser::SuggestResult more_relevant(
query, AutocompleteMatchType::SEARCH_HISTORY, query, base::string16(),
- base::string16(), base::string16(), base::string16(), std::string(),
- std::string(), false, 1300, true, false, query);
+ base::string16(), base::string16(), base::string16(), nullptr,
+ std::string(), std::string(), false, 1300, true, false, query);
provider_->AddMatchToMap(
more_relevant, std::string(), TemplateURLRef::NO_SUGGESTION_CHOSEN,
false, false, &map);
SearchSuggestionParser::SuggestResult less_relevant(
query, AutocompleteMatchType::SEARCH_SUGGEST, query, base::string16(),
- base::string16(), answer_contents, answer_type, std::string(),
- std::string(), false, 850, true, false, query);
+ base::string16(), answer_contents, answer_type,
+ SuggestionAnswer::copy(answer.get()), std::string(), std::string(),
+ false, 850, true, false, query);
provider_->AddMatchToMap(
less_relevant, std::string(), TemplateURLRef::NO_SUGGESTION_CHOSEN,
false, false, &map);
@@ -153,21 +157,27 @@ TEST_F(BaseSearchProviderTest, PreserveAnswersWhenDeduplicating) {
EXPECT_EQ(answer_contents, match.answer_contents);
EXPECT_EQ(answer_type, match.answer_type);
+ EXPECT_TRUE(answer->Equals(*match.answer));
EXPECT_EQ(AutocompleteMatchType::SEARCH_HISTORY, match.type);
EXPECT_EQ(1300, match.relevance);
EXPECT_EQ(answer_contents, duplicate.answer_contents);
EXPECT_EQ(answer_type, duplicate.answer_type);
+ EXPECT_TRUE(answer->Equals(*duplicate.answer));
EXPECT_EQ(AutocompleteMatchType::SEARCH_SUGGEST, duplicate.type);
EXPECT_EQ(850, duplicate.relevance);
// Ensure answers are not copied over existing answers.
map.clear();
base::string16 answer_contents2 = base::ASCIIToUTF16("different answer");
+ base::string16 answer_type2 = base::ASCIIToUTF16("8242");
+ scoped_ptr<SuggestionAnswer> answer2(new SuggestionAnswer());
+ answer2->set_type(8242);
more_relevant = SearchSuggestionParser::SuggestResult(
query, AutocompleteMatchType::SEARCH_HISTORY, query, base::string16(),
- base::string16(), answer_contents2, answer_type, std::string(),
- std::string(), false, 1300, true, false, query);
+ base::string16(), answer_contents2, answer_type2,
+ SuggestionAnswer::copy(answer2.get()), std::string(), std::string(),
+ false, 1300, true, false, query);
provider_->AddMatchToMap(
more_relevant, std::string(), TemplateURLRef::NO_SUGGESTION_CHOSEN,
false, false, &map);
@@ -180,13 +190,14 @@ TEST_F(BaseSearchProviderTest, PreserveAnswersWhenDeduplicating) {
duplicate = match.duplicate_matches[0];
EXPECT_EQ(answer_contents2, match.answer_contents);
- EXPECT_EQ(answer_type, match.answer_type);
+ EXPECT_EQ(answer_type2, match.answer_type);
+ EXPECT_TRUE(answer2->Equals(*match.answer));
EXPECT_EQ(AutocompleteMatchType::SEARCH_HISTORY, match.type);
EXPECT_EQ(1300, match.relevance);
EXPECT_EQ(answer_contents, duplicate.answer_contents);
EXPECT_EQ(answer_type, duplicate.answer_type);
+ EXPECT_TRUE(answer->Equals(*duplicate.answer));
EXPECT_EQ(AutocompleteMatchType::SEARCH_SUGGEST, duplicate.type);
EXPECT_EQ(850, duplicate.relevance);
-
}
« no previous file with comments | « components/omnibox/base_search_provider.cc ('k') | components/omnibox/search_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698