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

Unified Diff: components/search_engines/template_url_unittest.cc

Issue 939713003: Enabled the "search web for image" context menu item when "Yandex" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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: components/search_engines/template_url_unittest.cc
diff --git a/components/search_engines/template_url_unittest.cc b/components/search_engines/template_url_unittest.cc
index b16e7b42b1a644b055eb0bc9983b934c48f72349..c2222ee2b3ce9c5d73f65d3b4bba01c49766c6cd 100644
--- a/components/search_engines/template_url_unittest.cc
+++ b/components/search_engines/template_url_unittest.cc
@@ -158,10 +158,12 @@ TEST_F(TemplateURLTest, URLRefTestImageURLWithPOST) {
const TemplateURLRef::PostParams& bad_post_params =
url_bad.image_url_ref().post_params_;
ASSERT_EQ(2U, bad_post_params.size());
- EXPECT_EQ("unknown_template", bad_post_params[0].first);
- EXPECT_EQ("{UnknownTemplate}", bad_post_params[0].second);
- EXPECT_EQ("bad_value", bad_post_params[1].first);
- EXPECT_EQ("bad{value}", bad_post_params[1].second);
+ EXPECT_EQ("unknown_template", bad_post_params[0].value_name);
Peter Kasting 2015/02/18 21:55:52 Nit: Many of these place you're touching might get
Vitaly Baranov 2015/02/19 17:31:20 Done.
+ EXPECT_EQ("{UnknownTemplate}", bad_post_params[0].value);
+ EXPECT_TRUE(bad_post_params[0].content_type.empty());
+ EXPECT_EQ("bad_value", bad_post_params[1].value_name);
+ EXPECT_EQ("bad{value}", bad_post_params[1].value);
+ EXPECT_TRUE(bad_post_params[1].content_type.empty());
// Try to parse valid post parameters.
data.image_url_post_params = kValidPostParamsString;
@@ -172,6 +174,7 @@ TEST_F(TemplateURLTest, URLRefTestImageURLWithPOST) {
// Check term replacement.
TemplateURLRef::SearchTermsArgs search_args(ASCIIToUTF16("X"));
search_args.image_thumbnail_content = "dummy-image-thumbnail";
+ search_args.image_thumbnail_format = "jpeg";
search_args.image_url = GURL("http://dummyimage.com/dummy.jpg");
search_args.image_original_size = gfx::Size(10, 10);
// Replacement operation with no post_data buffer should still return
@@ -203,26 +206,32 @@ TEST_F(TemplateURLTest, URLRefTestImageURLWithPOST) {
static_cast<size_t>(i - post_params.begin())) {
switch (j->type) {
case TemplateURLRef::GOOGLE_IMAGE_ORIGINAL_WIDTH:
- EXPECT_EQ("width", i->first);
+ EXPECT_EQ("width", i->value_name);
EXPECT_EQ(
base::IntToString(search_args.image_original_size.width()),
- i->second);
+ i->value);
+ EXPECT_TRUE(i->content_type.empty());
break;
case TemplateURLRef::GOOGLE_IMAGE_SEARCH_SOURCE:
- EXPECT_EQ("sbisrc", i->first);
- EXPECT_EQ(search_terms_data.GoogleImageSearchSource(), i->second);
+ EXPECT_EQ("sbisrc", i->value_name);
+ EXPECT_EQ(search_terms_data.GoogleImageSearchSource(), i->value);
+ EXPECT_TRUE(i->content_type.empty());
break;
case TemplateURLRef::GOOGLE_IMAGE_THUMBNAIL:
- EXPECT_EQ("image_content", i->first);
- EXPECT_EQ(search_args.image_thumbnail_content, i->second);
+ EXPECT_EQ("image_content", i->value_name);
+ EXPECT_EQ(search_args.image_thumbnail_content, i->value);
+ EXPECT_EQ("image/" + search_args.image_thumbnail_format,
+ i->content_type);
break;
case TemplateURLRef::GOOGLE_IMAGE_URL:
- EXPECT_EQ("image_url", i->first);
- EXPECT_EQ(search_args.image_url.spec(), i->second);
+ EXPECT_EQ("image_url", i->value_name);
+ EXPECT_EQ(search_args.image_url.spec(), i->value);
+ EXPECT_TRUE(i->content_type.empty());
break;
case TemplateURLRef::LANGUAGE:
- EXPECT_EQ("language", i->first);
- EXPECT_EQ("en", i->second);
+ EXPECT_EQ("language", i->value_name);
+ EXPECT_EQ("en", i->value);
+ EXPECT_TRUE(i->content_type.empty());
break;
default:
ADD_FAILURE(); // Should never go here.
@@ -232,13 +241,16 @@ TEST_F(TemplateURLTest, URLRefTestImageURLWithPOST) {
}
if (j != replacements.end())
continue;
- if (i->first == "empty_param") {
- EXPECT_TRUE(i->second.empty());
- } else if (i->first == "sbisrc") {
- EXPECT_FALSE(i->second.empty());
+ if (i->value_name == "empty_param") {
+ EXPECT_TRUE(i->value.empty());
+ EXPECT_TRUE(i->content_type.empty());
+ } else if (i->value_name == "sbisrc") {
+ EXPECT_FALSE(i->value.empty());
+ EXPECT_TRUE(i->content_type.empty());
} else {
- EXPECT_EQ("constant_param", i->first);
- EXPECT_EQ("constant", i->second);
+ EXPECT_EQ("constant_param", i->value_name);
+ EXPECT_EQ("constant", i->value);
+ EXPECT_TRUE(i->content_type.empty());
}
}
}
« components/search_engines/template_url.h ('K') | « components/search_engines/template_url.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698