| OLD | NEW |
| 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/template_url.h" | 9 #include "chrome/browser/search_engines/template_url.h" |
| 10 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 10 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 EXPECT_NE("foi.com", t_urls[i]->favicon_url.host()); | 231 EXPECT_NE("foi.com", t_urls[i]->favicon_url.host()); |
| 232 EXPECT_NE("foo.com", GetHostFromTemplateURLData(*t_urls[i])); | 232 EXPECT_NE("foo.com", GetHostFromTemplateURLData(*t_urls[i])); |
| 233 EXPECT_NE(1001, t_urls[i]->prepopulate_id); | 233 EXPECT_NE(1001, t_urls[i]->prepopulate_id); |
| 234 } | 234 } |
| 235 // Ensures the default URL is Google and has the optional fields filled. | 235 // Ensures the default URL is Google and has the optional fields filled. |
| 236 EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name); | 236 EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name); |
| 237 EXPECT_FALSE(t_urls[default_index]->suggestions_url.empty()); | 237 EXPECT_FALSE(t_urls[default_index]->suggestions_url.empty()); |
| 238 EXPECT_FALSE(t_urls[default_index]->instant_url.empty()); | 238 EXPECT_FALSE(t_urls[default_index]->instant_url.empty()); |
| 239 EXPECT_FALSE(t_urls[default_index]->image_url.empty()); | 239 EXPECT_FALSE(t_urls[default_index]->image_url.empty()); |
| 240 EXPECT_FALSE(t_urls[default_index]->new_tab_url.empty()); | 240 EXPECT_FALSE(t_urls[default_index]->new_tab_url.empty()); |
| 241 EXPECT_FALSE(t_urls[default_index]->contextual_search_url.empty()); |
| 241 EXPECT_FALSE(t_urls[default_index]->image_url_post_params.empty()); | 242 EXPECT_FALSE(t_urls[default_index]->image_url_post_params.empty()); |
| 242 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, | 243 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, |
| 243 TemplateURLPrepopulateData::GetEngineType( | 244 TemplateURLPrepopulateData::GetEngineType( |
| 244 TemplateURL(NULL, *t_urls[default_index]))); | 245 TemplateURL(NULL, *t_urls[default_index]))); |
| 245 } | 246 } |
| 246 | 247 |
| 247 // Verifies that built-in search providers are processed correctly. | 248 // Verifies that built-in search providers are processed correctly. |
| 248 TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrepopulated) { | 249 TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrepopulated) { |
| 249 TestingProfile profile; | 250 TestingProfile profile; |
| 250 // Use United States. | 251 // Use United States. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 264 ASSERT_FALSE(t_urls[i]->input_encodings.empty()); | 265 ASSERT_FALSE(t_urls[i]->input_encodings.empty()); |
| 265 EXPECT_GT(t_urls[i]->prepopulate_id, 0); | 266 EXPECT_GT(t_urls[i]->prepopulate_id, 0); |
| 266 } | 267 } |
| 267 | 268 |
| 268 // Ensures the default URL is Google and has the optional fields filled. | 269 // Ensures the default URL is Google and has the optional fields filled. |
| 269 EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name); | 270 EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name); |
| 270 EXPECT_FALSE(t_urls[default_index]->suggestions_url.empty()); | 271 EXPECT_FALSE(t_urls[default_index]->suggestions_url.empty()); |
| 271 EXPECT_FALSE(t_urls[default_index]->instant_url.empty()); | 272 EXPECT_FALSE(t_urls[default_index]->instant_url.empty()); |
| 272 EXPECT_FALSE(t_urls[default_index]->image_url.empty()); | 273 EXPECT_FALSE(t_urls[default_index]->image_url.empty()); |
| 273 EXPECT_FALSE(t_urls[default_index]->new_tab_url.empty()); | 274 EXPECT_FALSE(t_urls[default_index]->new_tab_url.empty()); |
| 275 EXPECT_FALSE(t_urls[default_index]->contextual_search_url.empty()); |
| 274 EXPECT_FALSE(t_urls[default_index]->image_url_post_params.empty()); | 276 EXPECT_FALSE(t_urls[default_index]->image_url_post_params.empty()); |
| 275 // Expect at least 2 alternate_urls. | 277 // Expect at least 2 alternate_urls. |
| 276 // This caught a bug with static initialization of arrays, so leave this in. | 278 // This caught a bug with static initialization of arrays, so leave this in. |
| 277 EXPECT_GT(t_urls[default_index]->alternate_urls.size(), 1u); | 279 EXPECT_GT(t_urls[default_index]->alternate_urls.size(), 1u); |
| 278 for (size_t i = 0; i < t_urls[default_index]->alternate_urls.size(); ++i) | 280 for (size_t i = 0; i < t_urls[default_index]->alternate_urls.size(); ++i) |
| 279 EXPECT_FALSE(t_urls[default_index]->alternate_urls[i].empty()); | 281 EXPECT_FALSE(t_urls[default_index]->alternate_urls[i].empty()); |
| 280 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, | 282 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, |
| 281 TemplateURLPrepopulateData::GetEngineType( | 283 TemplateURLPrepopulateData::GetEngineType( |
| 282 TemplateURL(NULL, *t_urls[default_index]))); | 284 TemplateURL(NULL, *t_urls[default_index]))); |
| 283 EXPECT_FALSE(t_urls[default_index]->search_terms_replacement_key.empty()); | 285 EXPECT_FALSE(t_urls[default_index]->search_terms_replacement_key.empty()); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 | 369 |
| 368 TEST(TemplateURLPrepopulateDataTest, GetLogoURLInvalid) { | 370 TEST(TemplateURLPrepopulateDataTest, GetLogoURLInvalid) { |
| 369 TemplateURLData data; | 371 TemplateURLData data; |
| 370 data.SetURL("http://invalid:search:url/"); | 372 data.SetURL("http://invalid:search:url/"); |
| 371 TemplateURL turl(NULL, data); | 373 TemplateURL turl(NULL, data); |
| 372 GURL logo_url = TemplateURLPrepopulateData::GetLogoURL( | 374 GURL logo_url = TemplateURLPrepopulateData::GetLogoURL( |
| 373 turl, TemplateURLPrepopulateData::LOGO_100_PERCENT); | 375 turl, TemplateURLPrepopulateData::LOGO_100_PERCENT); |
| 374 | 376 |
| 375 EXPECT_TRUE(logo_url.is_empty()); | 377 EXPECT_TRUE(logo_url.is_empty()); |
| 376 } | 378 } |
| OLD | NEW |