OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/search_engines/template_url_prepopulate_data.h" | 5 #include "components/search_engines/template_url_prepopulate_data.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 unique_ids.end()); | 113 unique_ids.end()); |
114 unique_ids.insert(urls[turl_i]->prepopulate_id); | 114 unique_ids.insert(urls[turl_i]->prepopulate_id); |
115 } | 115 } |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 // Verifies that default search providers from the preferences file | 119 // Verifies that default search providers from the preferences file |
120 // override the built-in ones. | 120 // override the built-in ones. |
121 TEST_F(TemplateURLPrepopulateDataTest, ProvidersFromPrefs) { | 121 TEST_F(TemplateURLPrepopulateDataTest, ProvidersFromPrefs) { |
122 prefs_.SetUserPref(prefs::kSearchProviderOverridesVersion, | 122 prefs_.SetUserPref(prefs::kSearchProviderOverridesVersion, |
123 new base::FundamentalValue(1)); | 123 new base::Value(1)); |
124 base::ListValue* overrides = new base::ListValue; | 124 base::ListValue* overrides = new base::ListValue; |
125 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue); | 125 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
126 // Set only the minimal required settings for a search provider configuration. | 126 // Set only the minimal required settings for a search provider configuration. |
127 entry->SetString("name", "foo"); | 127 entry->SetString("name", "foo"); |
128 entry->SetString("keyword", "fook"); | 128 entry->SetString("keyword", "fook"); |
129 entry->SetString("search_url", "http://foo.com/s?q={searchTerms}"); | 129 entry->SetString("search_url", "http://foo.com/s?q={searchTerms}"); |
130 entry->SetString("favicon_url", "http://foi.com/favicon.ico"); | 130 entry->SetString("favicon_url", "http://foi.com/favicon.ico"); |
131 entry->SetString("encoding", "UTF-8"); | 131 entry->SetString("encoding", "UTF-8"); |
132 entry->SetInteger("id", 1001); | 132 entry->SetInteger("id", 1001); |
133 overrides->Append(entry->CreateDeepCopy()); | 133 overrides->Append(entry->CreateDeepCopy()); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 prefs_.SetUserPref(prefs::kSearchProviderOverrides, overrides); | 202 prefs_.SetUserPref(prefs::kSearchProviderOverrides, overrides); |
203 | 203 |
204 t_urls = | 204 t_urls = |
205 TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs_, | 205 TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs_, |
206 &default_index); | 206 &default_index); |
207 EXPECT_EQ(2u, t_urls.size()); | 207 EXPECT_EQ(2u, t_urls.size()); |
208 } | 208 } |
209 | 209 |
210 TEST_F(TemplateURLPrepopulateDataTest, ClearProvidersFromPrefs) { | 210 TEST_F(TemplateURLPrepopulateDataTest, ClearProvidersFromPrefs) { |
211 prefs_.SetUserPref(prefs::kSearchProviderOverridesVersion, | 211 prefs_.SetUserPref(prefs::kSearchProviderOverridesVersion, |
212 new base::FundamentalValue(1)); | 212 new base::Value(1)); |
213 base::ListValue* overrides = new base::ListValue; | 213 base::ListValue* overrides = new base::ListValue; |
214 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue); | 214 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
215 // Set only the minimal required settings for a search provider configuration. | 215 // Set only the minimal required settings for a search provider configuration. |
216 entry->SetString("name", "foo"); | 216 entry->SetString("name", "foo"); |
217 entry->SetString("keyword", "fook"); | 217 entry->SetString("keyword", "fook"); |
218 entry->SetString("search_url", "http://foo.com/s?q={searchTerms}"); | 218 entry->SetString("search_url", "http://foo.com/s?q={searchTerms}"); |
219 entry->SetString("favicon_url", "http://foi.com/favicon.ico"); | 219 entry->SetString("favicon_url", "http://foi.com/favicon.ico"); |
220 entry->SetString("encoding", "UTF-8"); | 220 entry->SetString("encoding", "UTF-8"); |
221 entry->SetInteger("id", 1001); | 221 entry->SetInteger("id", 1001); |
222 overrides->Append(std::move(entry)); | 222 overrides->Append(std::move(entry)); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 using PrepopulatedEngine = TemplateURLPrepopulateData::PrepopulatedEngine; | 360 using PrepopulatedEngine = TemplateURLPrepopulateData::PrepopulatedEngine; |
361 const std::vector<const PrepopulatedEngine*> all_engines = | 361 const std::vector<const PrepopulatedEngine*> all_engines = |
362 TemplateURLPrepopulateData::GetAllPrepopulatedEngines(); | 362 TemplateURLPrepopulateData::GetAllPrepopulatedEngines(); |
363 for (const PrepopulatedEngine* engine : all_engines) { | 363 for (const PrepopulatedEngine* engine : all_engines) { |
364 std::unique_ptr<TemplateURLData> data = | 364 std::unique_ptr<TemplateURLData> data = |
365 TemplateURLDataFromPrepopulatedEngine(*engine); | 365 TemplateURLDataFromPrepopulatedEngine(*engine); |
366 EXPECT_EQ(engine->type, | 366 EXPECT_EQ(engine->type, |
367 TemplateURL(*data).GetEngineType(SearchTermsData())); | 367 TemplateURL(*data).GetEngineType(SearchTermsData())); |
368 } | 368 } |
369 } | 369 } |
OLD | NEW |