Chromium Code Reviews| 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" |
| 11 #include "chrome/browser/search_engines/template_url_service.h" | 11 #include "chrome/browser/search_engines/template_url_service.h" |
| 12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 14 #include "chrome/test/base/testing_pref_service_syncable.h" | |
| 15 #include "chrome/test/base/testing_profile.h" | |
| 16 #include "components/google/core/browser/google_switches.h" | 14 #include "components/google/core/browser/google_switches.h" |
| 15 #include "components/pref_registry/testing_pref_service_syncable.h" | |
| 17 #include "components/search_engines/prepopulated_engines.h" | 16 #include "components/search_engines/prepopulated_engines.h" |
| 18 #include "components/search_engines/search_terms_data.h" | 17 #include "components/search_engines/search_terms_data.h" |
| 19 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 22 | 21 |
| 23 using base::ASCIIToUTF16; | 22 using base::ASCIIToUTF16; |
| 24 | 23 |
| 25 namespace { | 24 namespace { |
| 26 | 25 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 'S'<<8|'M', 'S'<<8|'N', 'S'<<8|'O', 'S'<<8|'R', 'S'<<8|'T', | 85 'S'<<8|'M', 'S'<<8|'N', 'S'<<8|'O', 'S'<<8|'R', 'S'<<8|'T', |
| 87 'S'<<8|'V', 'S'<<8|'Y', 'S'<<8|'Z', 'T'<<8|'C', 'T'<<8|'D', | 86 'S'<<8|'V', 'S'<<8|'Y', 'S'<<8|'Z', 'T'<<8|'C', 'T'<<8|'D', |
| 88 'T'<<8|'F', 'T'<<8|'G', 'T'<<8|'H', 'T'<<8|'J', 'T'<<8|'K', | 87 'T'<<8|'F', 'T'<<8|'G', 'T'<<8|'H', 'T'<<8|'J', 'T'<<8|'K', |
| 89 'T'<<8|'L', 'T'<<8|'M', 'T'<<8|'N', 'T'<<8|'O', 'T'<<8|'R', | 88 'T'<<8|'L', 'T'<<8|'M', 'T'<<8|'N', 'T'<<8|'O', 'T'<<8|'R', |
| 90 'T'<<8|'T', 'T'<<8|'V', 'T'<<8|'W', 'T'<<8|'Z', 'U'<<8|'A', | 89 'T'<<8|'T', 'T'<<8|'V', 'T'<<8|'W', 'T'<<8|'Z', 'U'<<8|'A', |
| 91 'U'<<8|'G', 'U'<<8|'M', 'U'<<8|'S', 'U'<<8|'Y', 'U'<<8|'Z', | 90 'U'<<8|'G', 'U'<<8|'M', 'U'<<8|'S', 'U'<<8|'Y', 'U'<<8|'Z', |
| 92 'V'<<8|'A', 'V'<<8|'C', 'V'<<8|'E', 'V'<<8|'G', 'V'<<8|'I', | 91 'V'<<8|'A', 'V'<<8|'C', 'V'<<8|'E', 'V'<<8|'G', 'V'<<8|'I', |
| 93 'V'<<8|'N', 'V'<<8|'U', 'W'<<8|'F', 'W'<<8|'S', 'Y'<<8|'E', | 92 'V'<<8|'N', 'V'<<8|'U', 'W'<<8|'F', 'W'<<8|'S', 'Y'<<8|'E', |
| 94 'Y'<<8|'T', 'Z'<<8|'A', 'Z'<<8|'M', 'Z'<<8|'W', -1 }; | 93 'Y'<<8|'T', 'Z'<<8|'A', 'Z'<<8|'M', 'Z'<<8|'W', -1 }; |
| 95 | 94 |
| 96 TestingProfile profile; | 95 user_prefs::TestingPrefServiceSyncable prefs; |
| 96 TemplateURLPrepopulateData::RegisterProfilePrefs(prefs.registry()); | |
|
Peter Kasting
2014/06/18 20:27:13
You seem to do this in every test, so I suggest co
hashimoto
2014/06/18 21:09:33
Done.
Added a test fixture and replaced all TEST w
| |
| 97 for (size_t i = 0; i < arraysize(kCountryIds); ++i) { | 97 for (size_t i = 0; i < arraysize(kCountryIds); ++i) { |
| 98 profile.GetPrefs()->SetInteger(prefs::kCountryIDAtInstall, kCountryIds[i]); | 98 prefs.SetInteger(prefs::kCountryIDAtInstall, kCountryIds[i]); |
| 99 size_t default_index; | 99 size_t default_index; |
| 100 ScopedVector<TemplateURLData> urls = | 100 ScopedVector<TemplateURLData> urls = |
| 101 TemplateURLPrepopulateData::GetPrepopulatedEngines(profile.GetPrefs(), | 101 TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs, |
| 102 &default_index); | 102 &default_index); |
| 103 std::set<int> unique_ids; | 103 std::set<int> unique_ids; |
| 104 for (size_t turl_i = 0; turl_i < urls.size(); ++turl_i) { | 104 for (size_t turl_i = 0; turl_i < urls.size(); ++turl_i) { |
| 105 ASSERT_TRUE(unique_ids.find(urls[turl_i]->prepopulate_id) == | 105 ASSERT_TRUE(unique_ids.find(urls[turl_i]->prepopulate_id) == |
| 106 unique_ids.end()); | 106 unique_ids.end()); |
| 107 unique_ids.insert(urls[turl_i]->prepopulate_id); | 107 unique_ids.insert(urls[turl_i]->prepopulate_id); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 // Verifies that default search providers from the preferences file | 112 // Verifies that default search providers from the preferences file |
| 113 // override the built-in ones. | 113 // override the built-in ones. |
| 114 TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrefs) { | 114 TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrefs) { |
| 115 TestingProfile profile; | 115 user_prefs::TestingPrefServiceSyncable prefs; |
| 116 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); | 116 TemplateURLPrepopulateData::RegisterProfilePrefs(prefs.registry()); |
| 117 prefs->SetUserPref(prefs::kSearchProviderOverridesVersion, | 117 prefs.SetUserPref(prefs::kSearchProviderOverridesVersion, |
| 118 base::Value::CreateIntegerValue(1)); | 118 base::Value::CreateIntegerValue(1)); |
| 119 base::ListValue* overrides = new base::ListValue; | 119 base::ListValue* overrides = new base::ListValue; |
| 120 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); | 120 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
| 121 // Set only the minimal required settings for a search provider configuration. | 121 // Set only the minimal required settings for a search provider configuration. |
| 122 entry->SetString("name", "foo"); | 122 entry->SetString("name", "foo"); |
| 123 entry->SetString("keyword", "fook"); | 123 entry->SetString("keyword", "fook"); |
| 124 entry->SetString("search_url", "http://foo.com/s?q={searchTerms}"); | 124 entry->SetString("search_url", "http://foo.com/s?q={searchTerms}"); |
| 125 entry->SetString("favicon_url", "http://foi.com/favicon.ico"); | 125 entry->SetString("favicon_url", "http://foi.com/favicon.ico"); |
| 126 entry->SetString("encoding", "UTF-8"); | 126 entry->SetString("encoding", "UTF-8"); |
| 127 entry->SetInteger("id", 1001); | 127 entry->SetInteger("id", 1001); |
| 128 overrides->Append(entry->DeepCopy()); | 128 overrides->Append(entry->DeepCopy()); |
| 129 prefs->SetUserPref(prefs::kSearchProviderOverrides, overrides); | 129 prefs.SetUserPref(prefs::kSearchProviderOverrides, overrides); |
| 130 | 130 |
| 131 int version = TemplateURLPrepopulateData::GetDataVersion(prefs); | 131 int version = TemplateURLPrepopulateData::GetDataVersion(&prefs); |
| 132 EXPECT_EQ(1, version); | 132 EXPECT_EQ(1, version); |
| 133 | 133 |
| 134 size_t default_index; | 134 size_t default_index; |
| 135 ScopedVector<TemplateURLData> t_urls = | 135 ScopedVector<TemplateURLData> t_urls = |
| 136 TemplateURLPrepopulateData::GetPrepopulatedEngines(prefs, &default_index); | 136 TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs, |
| 137 &default_index); | |
| 137 | 138 |
| 138 ASSERT_EQ(1u, t_urls.size()); | 139 ASSERT_EQ(1u, t_urls.size()); |
| 139 EXPECT_EQ(ASCIIToUTF16("foo"), t_urls[0]->short_name); | 140 EXPECT_EQ(ASCIIToUTF16("foo"), t_urls[0]->short_name); |
| 140 EXPECT_EQ(ASCIIToUTF16("fook"), t_urls[0]->keyword()); | 141 EXPECT_EQ(ASCIIToUTF16("fook"), t_urls[0]->keyword()); |
| 141 EXPECT_EQ("foo.com", GetHostFromTemplateURLData(*t_urls[0])); | 142 EXPECT_EQ("foo.com", GetHostFromTemplateURLData(*t_urls[0])); |
| 142 EXPECT_EQ("foi.com", t_urls[0]->favicon_url.host()); | 143 EXPECT_EQ("foi.com", t_urls[0]->favicon_url.host()); |
| 143 EXPECT_EQ(1u, t_urls[0]->input_encodings.size()); | 144 EXPECT_EQ(1u, t_urls[0]->input_encodings.size()); |
| 144 EXPECT_EQ(1001, t_urls[0]->prepopulate_id); | 145 EXPECT_EQ(1001, t_urls[0]->prepopulate_id); |
| 145 EXPECT_TRUE(t_urls[0]->suggestions_url.empty()); | 146 EXPECT_TRUE(t_urls[0]->suggestions_url.empty()); |
| 146 EXPECT_TRUE(t_urls[0]->instant_url.empty()); | 147 EXPECT_TRUE(t_urls[0]->instant_url.empty()); |
| 147 EXPECT_EQ(0u, t_urls[0]->alternate_urls.size()); | 148 EXPECT_EQ(0u, t_urls[0]->alternate_urls.size()); |
| 148 EXPECT_TRUE(t_urls[0]->search_terms_replacement_key.empty()); | 149 EXPECT_TRUE(t_urls[0]->search_terms_replacement_key.empty()); |
| 149 | 150 |
| 150 // Test the optional settings too. | 151 // Test the optional settings too. |
| 151 entry->SetString("suggest_url", "http://foo.com/suggest?q={searchTerms}"); | 152 entry->SetString("suggest_url", "http://foo.com/suggest?q={searchTerms}"); |
| 152 entry->SetString("instant_url", "http://foo.com/instant?q={searchTerms}"); | 153 entry->SetString("instant_url", "http://foo.com/instant?q={searchTerms}"); |
| 153 base::ListValue* alternate_urls = new base::ListValue; | 154 base::ListValue* alternate_urls = new base::ListValue; |
| 154 alternate_urls->AppendString("http://foo.com/alternate?q={searchTerms}"); | 155 alternate_urls->AppendString("http://foo.com/alternate?q={searchTerms}"); |
| 155 entry->Set("alternate_urls", alternate_urls); | 156 entry->Set("alternate_urls", alternate_urls); |
| 156 entry->SetString("search_terms_replacement_key", "espv"); | 157 entry->SetString("search_terms_replacement_key", "espv"); |
| 157 overrides = new base::ListValue; | 158 overrides = new base::ListValue; |
| 158 overrides->Append(entry->DeepCopy()); | 159 overrides->Append(entry->DeepCopy()); |
| 159 prefs->SetUserPref(prefs::kSearchProviderOverrides, overrides); | 160 prefs.SetUserPref(prefs::kSearchProviderOverrides, overrides); |
| 160 | 161 |
| 161 t_urls = TemplateURLPrepopulateData::GetPrepopulatedEngines( | 162 t_urls = TemplateURLPrepopulateData::GetPrepopulatedEngines( |
| 162 profile.GetPrefs(), &default_index); | 163 &prefs, &default_index); |
| 163 ASSERT_EQ(1u, t_urls.size()); | 164 ASSERT_EQ(1u, t_urls.size()); |
| 164 EXPECT_EQ(ASCIIToUTF16("foo"), t_urls[0]->short_name); | 165 EXPECT_EQ(ASCIIToUTF16("foo"), t_urls[0]->short_name); |
| 165 EXPECT_EQ(ASCIIToUTF16("fook"), t_urls[0]->keyword()); | 166 EXPECT_EQ(ASCIIToUTF16("fook"), t_urls[0]->keyword()); |
| 166 EXPECT_EQ("foo.com", GetHostFromTemplateURLData(*t_urls[0])); | 167 EXPECT_EQ("foo.com", GetHostFromTemplateURLData(*t_urls[0])); |
| 167 EXPECT_EQ("foi.com", t_urls[0]->favicon_url.host()); | 168 EXPECT_EQ("foi.com", t_urls[0]->favicon_url.host()); |
| 168 EXPECT_EQ(1u, t_urls[0]->input_encodings.size()); | 169 EXPECT_EQ(1u, t_urls[0]->input_encodings.size()); |
| 169 EXPECT_EQ(1001, t_urls[0]->prepopulate_id); | 170 EXPECT_EQ(1001, t_urls[0]->prepopulate_id); |
| 170 EXPECT_EQ("http://foo.com/suggest?q={searchTerms}", | 171 EXPECT_EQ("http://foo.com/suggest?q={searchTerms}", |
| 171 t_urls[0]->suggestions_url); | 172 t_urls[0]->suggestions_url); |
| 172 EXPECT_EQ("http://foo.com/instant?q={searchTerms}", | 173 EXPECT_EQ("http://foo.com/instant?q={searchTerms}", |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 183 entry->SetInteger("id", 1002); | 184 entry->SetInteger("id", 1002); |
| 184 entry->SetString("name", "bar"); | 185 entry->SetString("name", "bar"); |
| 185 entry->SetString("keyword", "bark"); | 186 entry->SetString("keyword", "bark"); |
| 186 entry->SetString("encoding", std::string()); | 187 entry->SetString("encoding", std::string()); |
| 187 overrides->Append(entry->DeepCopy()); | 188 overrides->Append(entry->DeepCopy()); |
| 188 entry->SetInteger("id", 1003); | 189 entry->SetInteger("id", 1003); |
| 189 entry->SetString("name", "baz"); | 190 entry->SetString("name", "baz"); |
| 190 entry->SetString("keyword", "bazk"); | 191 entry->SetString("keyword", "bazk"); |
| 191 entry->SetString("encoding", "UTF-8"); | 192 entry->SetString("encoding", "UTF-8"); |
| 192 overrides->Append(entry->DeepCopy()); | 193 overrides->Append(entry->DeepCopy()); |
| 193 prefs->SetUserPref(prefs::kSearchProviderOverrides, overrides); | 194 prefs.SetUserPref(prefs::kSearchProviderOverrides, overrides); |
| 194 | 195 |
| 195 t_urls = | 196 t_urls = |
| 196 TemplateURLPrepopulateData::GetPrepopulatedEngines(prefs, &default_index); | 197 TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs, |
| 198 &default_index); | |
| 197 EXPECT_EQ(2u, t_urls.size()); | 199 EXPECT_EQ(2u, t_urls.size()); |
| 198 } | 200 } |
| 199 | 201 |
| 200 TEST(TemplateURLPrepopulateDataTest, ClearProvidersFromPrefs) { | 202 TEST(TemplateURLPrepopulateDataTest, ClearProvidersFromPrefs) { |
| 201 TestingProfile profile; | 203 user_prefs::TestingPrefServiceSyncable prefs; |
| 202 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); | 204 TemplateURLPrepopulateData::RegisterProfilePrefs(prefs.registry()); |
| 203 prefs->SetUserPref(prefs::kSearchProviderOverridesVersion, | 205 prefs.SetUserPref(prefs::kSearchProviderOverridesVersion, |
| 204 base::Value::CreateIntegerValue(1)); | 206 base::Value::CreateIntegerValue(1)); |
| 205 base::ListValue* overrides = new base::ListValue; | 207 base::ListValue* overrides = new base::ListValue; |
| 206 base::DictionaryValue* entry(new base::DictionaryValue); | 208 base::DictionaryValue* entry(new base::DictionaryValue); |
| 207 // Set only the minimal required settings for a search provider configuration. | 209 // Set only the minimal required settings for a search provider configuration. |
| 208 entry->SetString("name", "foo"); | 210 entry->SetString("name", "foo"); |
| 209 entry->SetString("keyword", "fook"); | 211 entry->SetString("keyword", "fook"); |
| 210 entry->SetString("search_url", "http://foo.com/s?q={searchTerms}"); | 212 entry->SetString("search_url", "http://foo.com/s?q={searchTerms}"); |
| 211 entry->SetString("favicon_url", "http://foi.com/favicon.ico"); | 213 entry->SetString("favicon_url", "http://foi.com/favicon.ico"); |
| 212 entry->SetString("encoding", "UTF-8"); | 214 entry->SetString("encoding", "UTF-8"); |
| 213 entry->SetInteger("id", 1001); | 215 entry->SetInteger("id", 1001); |
| 214 overrides->Append(entry); | 216 overrides->Append(entry); |
| 215 prefs->SetUserPref(prefs::kSearchProviderOverrides, overrides); | 217 prefs.SetUserPref(prefs::kSearchProviderOverrides, overrides); |
| 216 | 218 |
| 217 int version = TemplateURLPrepopulateData::GetDataVersion(prefs); | 219 int version = TemplateURLPrepopulateData::GetDataVersion(&prefs); |
| 218 EXPECT_EQ(1, version); | 220 EXPECT_EQ(1, version); |
| 219 | 221 |
| 220 // This call removes the above search engine. | 222 // This call removes the above search engine. |
| 221 TemplateURLPrepopulateData::ClearPrepopulatedEnginesInPrefs(prefs); | 223 TemplateURLPrepopulateData::ClearPrepopulatedEnginesInPrefs(&prefs); |
| 222 | 224 |
| 223 version = TemplateURLPrepopulateData::GetDataVersion(prefs); | 225 version = TemplateURLPrepopulateData::GetDataVersion(&prefs); |
| 224 EXPECT_EQ(TemplateURLPrepopulateData::kCurrentDataVersion, version); | 226 EXPECT_EQ(TemplateURLPrepopulateData::kCurrentDataVersion, version); |
| 225 | 227 |
| 226 size_t default_index; | 228 size_t default_index; |
| 227 ScopedVector<TemplateURLData> t_urls = | 229 ScopedVector<TemplateURLData> t_urls = |
| 228 TemplateURLPrepopulateData::GetPrepopulatedEngines(prefs, &default_index); | 230 TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs, |
| 231 &default_index); | |
| 229 ASSERT_FALSE(t_urls.empty()); | 232 ASSERT_FALSE(t_urls.empty()); |
| 230 for (size_t i = 0; i < t_urls.size(); ++i) { | 233 for (size_t i = 0; i < t_urls.size(); ++i) { |
| 231 EXPECT_NE(ASCIIToUTF16("foo"), t_urls[i]->short_name); | 234 EXPECT_NE(ASCIIToUTF16("foo"), t_urls[i]->short_name); |
| 232 EXPECT_NE(ASCIIToUTF16("fook"), t_urls[i]->keyword()); | 235 EXPECT_NE(ASCIIToUTF16("fook"), t_urls[i]->keyword()); |
| 233 EXPECT_NE("foi.com", t_urls[i]->favicon_url.host()); | 236 EXPECT_NE("foi.com", t_urls[i]->favicon_url.host()); |
| 234 EXPECT_NE("foo.com", GetHostFromTemplateURLData(*t_urls[i])); | 237 EXPECT_NE("foo.com", GetHostFromTemplateURLData(*t_urls[i])); |
| 235 EXPECT_NE(1001, t_urls[i]->prepopulate_id); | 238 EXPECT_NE(1001, t_urls[i]->prepopulate_id); |
| 236 } | 239 } |
| 237 // Ensures the default URL is Google and has the optional fields filled. | 240 // Ensures the default URL is Google and has the optional fields filled. |
| 238 EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name); | 241 EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name); |
| 239 EXPECT_FALSE(t_urls[default_index]->suggestions_url.empty()); | 242 EXPECT_FALSE(t_urls[default_index]->suggestions_url.empty()); |
| 240 EXPECT_FALSE(t_urls[default_index]->instant_url.empty()); | 243 EXPECT_FALSE(t_urls[default_index]->instant_url.empty()); |
| 241 EXPECT_FALSE(t_urls[default_index]->image_url.empty()); | 244 EXPECT_FALSE(t_urls[default_index]->image_url.empty()); |
| 242 EXPECT_FALSE(t_urls[default_index]->new_tab_url.empty()); | 245 EXPECT_FALSE(t_urls[default_index]->new_tab_url.empty()); |
| 243 EXPECT_FALSE(t_urls[default_index]->contextual_search_url.empty()); | 246 EXPECT_FALSE(t_urls[default_index]->contextual_search_url.empty()); |
| 244 EXPECT_FALSE(t_urls[default_index]->image_url_post_params.empty()); | 247 EXPECT_FALSE(t_urls[default_index]->image_url_post_params.empty()); |
| 245 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, | 248 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, |
| 246 TemplateURLPrepopulateData::GetEngineType( | 249 TemplateURLPrepopulateData::GetEngineType( |
| 247 TemplateURL(*t_urls[default_index]), | 250 TemplateURL(*t_urls[default_index]), |
| 248 SearchTermsData())); | 251 SearchTermsData())); |
| 249 } | 252 } |
| 250 | 253 |
| 251 // Verifies that built-in search providers are processed correctly. | 254 // Verifies that built-in search providers are processed correctly. |
| 252 TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrepopulated) { | 255 TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrepopulated) { |
| 253 TestingProfile profile; | 256 user_prefs::TestingPrefServiceSyncable prefs; |
| 257 TemplateURLPrepopulateData::RegisterProfilePrefs(prefs.registry()); | |
| 254 // Use United States. | 258 // Use United States. |
| 255 profile.GetPrefs()->SetInteger(prefs::kCountryIDAtInstall, 'U'<<8|'S'); | 259 prefs.SetInteger(prefs::kCountryIDAtInstall, 'U'<<8|'S'); |
| 256 size_t default_index; | 260 size_t default_index; |
| 257 ScopedVector<TemplateURLData> t_urls = | 261 ScopedVector<TemplateURLData> t_urls = |
| 258 TemplateURLPrepopulateData::GetPrepopulatedEngines(profile.GetPrefs(), | 262 TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs, |
| 259 &default_index); | 263 &default_index); |
| 260 | 264 |
| 261 // Ensure all the URLs have the required fields populated. | 265 // Ensure all the URLs have the required fields populated. |
| 262 ASSERT_FALSE(t_urls.empty()); | 266 ASSERT_FALSE(t_urls.empty()); |
| 263 for (size_t i = 0; i < t_urls.size(); ++i) { | 267 for (size_t i = 0; i < t_urls.size(); ++i) { |
| 264 ASSERT_FALSE(t_urls[i]->short_name.empty()); | 268 ASSERT_FALSE(t_urls[i]->short_name.empty()); |
| 265 ASSERT_FALSE(t_urls[i]->keyword().empty()); | 269 ASSERT_FALSE(t_urls[i]->keyword().empty()); |
| 266 ASSERT_FALSE(t_urls[i]->favicon_url.host().empty()); | 270 ASSERT_FALSE(t_urls[i]->favicon_url.host().empty()); |
| 267 ASSERT_FALSE(GetHostFromTemplateURLData(*t_urls[i]).empty()); | 271 ASSERT_FALSE(GetHostFromTemplateURLData(*t_urls[i]).empty()); |
| 268 ASSERT_FALSE(t_urls[i]->input_encodings.empty()); | 272 ASSERT_FALSE(t_urls[i]->input_encodings.empty()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 EXPECT_EQ(SEARCH_ENGINE_OTHER, GetEngineType("invalid:search:url")); | 343 EXPECT_EQ(SEARCH_ENGINE_OTHER, GetEngineType("invalid:search:url")); |
| 340 | 344 |
| 341 // URL that doesn't look Google-related, but matches a Google base URL | 345 // URL that doesn't look Google-related, but matches a Google base URL |
| 342 // specified on the command line. | 346 // specified on the command line. |
| 343 const std::string foo_url("http://www.foo.com/search?q={searchTerms}"); | 347 const std::string foo_url("http://www.foo.com/search?q={searchTerms}"); |
| 344 EXPECT_EQ(SEARCH_ENGINE_OTHER, GetEngineType(foo_url)); | 348 EXPECT_EQ(SEARCH_ENGINE_OTHER, GetEngineType(foo_url)); |
| 345 CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kGoogleBaseURL, | 349 CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kGoogleBaseURL, |
| 346 "http://www.foo.com/"); | 350 "http://www.foo.com/"); |
| 347 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, GetEngineType(foo_url)); | 351 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, GetEngineType(foo_url)); |
| 348 } | 352 } |
| OLD | NEW |