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

Unified Diff: chrome/browser/autocomplete/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: Respond to comments, fix a copy bug 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 | « no previous file | components/components_tests.gyp » ('j') | components/omnibox/autocomplete_match.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b77a6de014d66d446573e3b419318d1a993d6bde..5b82c523be1bd3e25e30b161e4b683f44526668d 100644
--- a/chrome/browser/autocomplete/search_provider_unittest.cc
+++ b/chrome/browser/autocomplete/search_provider_unittest.cc
@@ -39,6 +39,7 @@
#include "components/omnibox/autocomplete_provider_listener.h"
#include "components/omnibox/omnibox_field_trial.h"
#include "components/omnibox/omnibox_switches.h"
+#include "components/omnibox/suggestion_answer.h"
#include "components/search_engines/search_engine_type.h"
#include "components/search_engines/search_engines_switches.h"
#include "components/search_engines/search_terms_data.h"
@@ -3418,8 +3419,8 @@ TEST_F(SearchProviderTest, AnswersCache) {
base::string16 query = base::ASCIIToUTF16("weather los angeles");
SearchSuggestionParser::SuggestResult suggest_result(
query, AutocompleteMatchType::SEARCH_HISTORY, query, base::string16(),
- base::string16(), base::string16(), base::string16(), std::string(),
- std::string(), false, 1200, false, false, query);
+ base::string16(), base::string16(), base::string16(), nullptr,
+ std::string(), std::string(), false, 1200, false, false, query);
QueryForInput(ASCIIToUTF16("weather l"), false, false);
provider_->transformed_default_history_results_.push_back(suggest_result);
answer = provider_->FindAnswersPrefetchData();
@@ -3428,12 +3429,22 @@ TEST_F(SearchProviderTest, AnswersCache) {
}
TEST_F(SearchProviderTest, RemoveExtraAnswers) {
+ scoped_ptr<SuggestionAnswer> answer1(new SuggestionAnswer());
+ answer1->set_type(42);
+ scoped_ptr<SuggestionAnswer> answer2(new SuggestionAnswer());
+ answer2->set_type(1983);
+ scoped_ptr<SuggestionAnswer> answer3(new SuggestionAnswer());
+ answer3->set_type(423);
+
ACMatches matches;
AutocompleteMatch match1, match2, match3, match4, match5;
+ match1.answer = answer1.Pass();
groby-ooo-7-16 2014/10/30 20:28:29 If you call Pass() here, you relinquish ownership
Justin Donnelly 2014/10/30 21:38:03 Done. This passed because I didn't use to have th
match1.answer_contents = base::ASCIIToUTF16("the answer");
match1.answer_type = base::ASCIIToUTF16("42");
+ match3.answer = answer2.Pass();
match3.answer_contents = base::ASCIIToUTF16("not to play");
match3.answer_type = base::ASCIIToUTF16("1983");
+ match5.answer = answer3.Pass();
match5.answer_contents = base::ASCIIToUTF16("a man");
match5.answer_type = base::ASCIIToUTF16("423");
@@ -3446,12 +3457,17 @@ TEST_F(SearchProviderTest, RemoveExtraAnswers) {
SearchProvider::RemoveExtraAnswers(&matches);
EXPECT_EQ(base::ASCIIToUTF16("the answer"), matches[0].answer_contents);
EXPECT_EQ(base::ASCIIToUTF16("42"), matches[0].answer_type);
+ EXPECT_TRUE(answer1.Equals(*matches[0].answer));
EXPECT_TRUE(matches[1].answer_contents.empty());
EXPECT_TRUE(matches[1].answer_type.empty());
+ EXPECT_FALSE(matches[1].answer);
EXPECT_TRUE(matches[2].answer_contents.empty());
EXPECT_TRUE(matches[2].answer_type.empty());
+ EXPECT_FALSE(matches[2].answer);
EXPECT_TRUE(matches[3].answer_contents.empty());
EXPECT_TRUE(matches[3].answer_type.empty());
+ EXPECT_FALSE(matches[3].answer);
EXPECT_TRUE(matches[4].answer_contents.empty());
EXPECT_TRUE(matches[4].answer_type.empty());
+ EXPECT_FALSE(matches[4].answer);
}
« no previous file with comments | « no previous file | components/components_tests.gyp » ('j') | components/omnibox/autocomplete_match.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698