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

Side by Side Diff: chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc

Issue 308053009: Add contextual search to the template url system (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments and make contextual search /search requests accessible from Java. Created 6 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/search_engines/prepopulated_engines.h" 9 #include "chrome/browser/search_engines/prepopulated_engines.h"
10 #include "chrome/browser/search_engines/search_terms_data.h" 10 #include "chrome/browser/search_engines/search_terms_data.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 EXPECT_NE("foi.com", t_urls[i]->favicon_url.host()); 232 EXPECT_NE("foi.com", t_urls[i]->favicon_url.host());
233 EXPECT_NE("foo.com", GetHostFromTemplateURLData(*t_urls[i])); 233 EXPECT_NE("foo.com", GetHostFromTemplateURLData(*t_urls[i]));
234 EXPECT_NE(1001, t_urls[i]->prepopulate_id); 234 EXPECT_NE(1001, t_urls[i]->prepopulate_id);
235 } 235 }
236 // Ensures the default URL is Google and has the optional fields filled. 236 // Ensures the default URL is Google and has the optional fields filled.
237 EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name); 237 EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name);
238 EXPECT_FALSE(t_urls[default_index]->suggestions_url.empty()); 238 EXPECT_FALSE(t_urls[default_index]->suggestions_url.empty());
239 EXPECT_FALSE(t_urls[default_index]->instant_url.empty()); 239 EXPECT_FALSE(t_urls[default_index]->instant_url.empty());
240 EXPECT_FALSE(t_urls[default_index]->image_url.empty()); 240 EXPECT_FALSE(t_urls[default_index]->image_url.empty());
241 EXPECT_FALSE(t_urls[default_index]->new_tab_url.empty()); 241 EXPECT_FALSE(t_urls[default_index]->new_tab_url.empty());
242 EXPECT_FALSE(t_urls[default_index]->contextual_search_url.empty());
242 EXPECT_FALSE(t_urls[default_index]->image_url_post_params.empty()); 243 EXPECT_FALSE(t_urls[default_index]->image_url_post_params.empty());
243 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, 244 EXPECT_EQ(SEARCH_ENGINE_GOOGLE,
244 TemplateURLPrepopulateData::GetEngineType( 245 TemplateURLPrepopulateData::GetEngineType(
245 TemplateURL(NULL, *t_urls[default_index]))); 246 TemplateURL(NULL, *t_urls[default_index])));
246 } 247 }
247 248
248 // Verifies that built-in search providers are processed correctly. 249 // Verifies that built-in search providers are processed correctly.
249 TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrepopulated) { 250 TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrepopulated) {
250 TestingProfile profile; 251 TestingProfile profile;
251 // Use United States. 252 // Use United States.
(...skipping 13 matching lines...) Expand all
265 ASSERT_FALSE(t_urls[i]->input_encodings.empty()); 266 ASSERT_FALSE(t_urls[i]->input_encodings.empty());
266 EXPECT_GT(t_urls[i]->prepopulate_id, 0); 267 EXPECT_GT(t_urls[i]->prepopulate_id, 0);
267 } 268 }
268 269
269 // Ensures the default URL is Google and has the optional fields filled. 270 // Ensures the default URL is Google and has the optional fields filled.
270 EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name); 271 EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name);
271 EXPECT_FALSE(t_urls[default_index]->suggestions_url.empty()); 272 EXPECT_FALSE(t_urls[default_index]->suggestions_url.empty());
272 EXPECT_FALSE(t_urls[default_index]->instant_url.empty()); 273 EXPECT_FALSE(t_urls[default_index]->instant_url.empty());
273 EXPECT_FALSE(t_urls[default_index]->image_url.empty()); 274 EXPECT_FALSE(t_urls[default_index]->image_url.empty());
274 EXPECT_FALSE(t_urls[default_index]->new_tab_url.empty()); 275 EXPECT_FALSE(t_urls[default_index]->new_tab_url.empty());
276 EXPECT_FALSE(t_urls[default_index]->contextual_search_url.empty());
275 EXPECT_FALSE(t_urls[default_index]->image_url_post_params.empty()); 277 EXPECT_FALSE(t_urls[default_index]->image_url_post_params.empty());
276 // Expect at least 2 alternate_urls. 278 // Expect at least 2 alternate_urls.
277 // This caught a bug with static initialization of arrays, so leave this in. 279 // This caught a bug with static initialization of arrays, so leave this in.
278 EXPECT_GT(t_urls[default_index]->alternate_urls.size(), 1u); 280 EXPECT_GT(t_urls[default_index]->alternate_urls.size(), 1u);
279 for (size_t i = 0; i < t_urls[default_index]->alternate_urls.size(); ++i) 281 for (size_t i = 0; i < t_urls[default_index]->alternate_urls.size(); ++i)
280 EXPECT_FALSE(t_urls[default_index]->alternate_urls[i].empty()); 282 EXPECT_FALSE(t_urls[default_index]->alternate_urls[i].empty());
281 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, 283 EXPECT_EQ(SEARCH_ENGINE_GOOGLE,
282 TemplateURLPrepopulateData::GetEngineType( 284 TemplateURLPrepopulateData::GetEngineType(
283 TemplateURL(NULL, *t_urls[default_index]))); 285 TemplateURL(NULL, *t_urls[default_index])));
284 EXPECT_FALSE(t_urls[default_index]->search_terms_replacement_key.empty()); 286 EXPECT_FALSE(t_urls[default_index]->search_terms_replacement_key.empty());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 370
369 TEST(TemplateURLPrepopulateDataTest, GetLogoURLInvalid) { 371 TEST(TemplateURLPrepopulateDataTest, GetLogoURLInvalid) {
370 TemplateURLData data; 372 TemplateURLData data;
371 data.SetURL("http://invalid:search:url/"); 373 data.SetURL("http://invalid:search:url/");
372 TemplateURL turl(NULL, data); 374 TemplateURL turl(NULL, data);
373 GURL logo_url = TemplateURLPrepopulateData::GetLogoURL( 375 GURL logo_url = TemplateURLPrepopulateData::GetLogoURL(
374 turl, TemplateURLPrepopulateData::LOGO_100_PERCENT); 376 turl, TemplateURLPrepopulateData::LOGO_100_PERCENT);
375 377
376 EXPECT_TRUE(logo_url.is_empty()); 378 EXPECT_TRUE(logo_url.is_empty());
377 } 379 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698