Chromium Code Reviews| Index: chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc |
| diff --git a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc |
| index 324af6e2bed86e996ea3cbe88129f521a7735aa0..4249a62e7aead9b442c8c0fec1204fbfefa314f2 100644 |
| --- a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc |
| +++ b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc |
| @@ -2,6 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "base/command_line.h" |
| #include "base/file_util.h" |
| #include "base/memory/scoped_vector.h" |
| #include "base/scoped_temp_dir.h" |
| @@ -10,6 +11,7 @@ |
| #include "chrome/browser/search_engines/template_url.h" |
| #include "chrome/browser/search_engines/template_url_service.h" |
| #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
| +#include "chrome/common/chrome_switches.h" |
| #include "chrome/common/pref_names.h" |
| #include "chrome/test/base/testing_pref_service.h" |
| #include "chrome/test/base/testing_profile.h" |
| @@ -177,6 +179,41 @@ TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrefs) { |
| EXPECT_EQ(2u, t_urls.size()); |
| } |
| +// Verifies that built-in search providers are processed correctly. |
| +TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrepopulated) { |
| + // Use United States. |
| + CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| + switches::kCountry, "NO"); |
| + TestingProfile profile; |
| + ScopedVector<TemplateURL> t_urls; |
| + size_t default_index; |
| + TemplateURLPrepopulateData::GetPrepopulatedEngines(&profile, &t_urls.get(), |
| + &default_index); |
| + |
| + // Ensure all the URLs have the required fields populated. |
| + ASSERT_GT(t_urls.size(), 0u); |
|
Peter Kasting
2012/11/14 18:09:48
Nit: Or ASSERT_FALSE(t_urls.empty()), and similar
|
| + for (size_t i = 0; i < t_urls.size(); ++i) { |
| + EXPECT_GT(t_urls[i]->short_name().size(), 0u); |
| + EXPECT_GT(t_urls[i]->keyword().size(), 0u); |
| + EXPECT_GT(t_urls[i]->favicon_url().host().size(), 0u); |
| + EXPECT_GT(t_urls[i]->url_ref().GetHost().size(), 0u); |
| + EXPECT_GT(t_urls[i]->input_encodings().size(), 0u); |
| + EXPECT_GT(t_urls[i]->prepopulate_id(), 0); |
| + } |
| + |
| + // Ensures the default URL is Google and has the optional fields filled. |
| + EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name()); |
| + EXPECT_GT(t_urls[default_index]->suggestions_url().size(), 0u); |
| + EXPECT_GT(t_urls[default_index]->instant_url().size(), 0u); |
| + // Expect at least 2 alternate_urls. |
| + // This caught a bug with static initialization of arrays, so leave this in. |
| + EXPECT_GT(t_urls[default_index]->alternate_urls().size(), 1u); |
| + for (size_t i = 0; i < t_urls[default_index]->alternate_urls().size(); ++i) |
| + EXPECT_GT(t_urls[default_index]->alternate_urls()[i].size(), 0u); |
| + EXPECT_EQ(SEARCH_ENGINE_GOOGLE, |
| + TemplateURLPrepopulateData::GetEngineType(t_urls[default_index]->url())); |
| +} |
| + |
| TEST(TemplateURLPrepopulateDataTest, GetEngineTypeBasic) { |
| EXPECT_EQ(SEARCH_ENGINE_OTHER, |
| TemplateURLPrepopulateData::GetEngineType("http://example.com/")); |