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

Unified Diff: chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc

Issue 11170007: Make some of the search engine configuration data from master_preferences optional. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/search_engines/template_url_prepopulate_data.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 542e9d1b37f51f153d2b7f389730610b89d8886a..324af6e2bed86e996ea3cbe88129f521a7735aa0 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
@@ -97,17 +97,15 @@ TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrefs) {
prefs->SetUserPref(prefs::kSearchProviderOverridesVersion,
Value::CreateIntegerValue(1));
ListValue* overrides = new ListValue;
- DictionaryValue* entry = new DictionaryValue;
+ scoped_ptr<DictionaryValue> entry(new DictionaryValue);
+ // Set only the minimal required settings for a search provider configuration.
entry->SetString("name", "foo");
entry->SetString("keyword", "fook");
entry->SetString("search_url", "http://foo.com/s?q={searchTerms}");
entry->SetString("favicon_url", "http://foi.com/favicon.ico");
- entry->SetString("suggest_url", "");
- entry->SetString("instant_url", "");
- entry->Set("alternate_urls", new ListValue());
entry->SetString("encoding", "UTF-8");
entry->SetInteger("id", 1001);
- overrides->Append(entry);
+ overrides->Append(entry->DeepCopy());
prefs->SetUserPref(prefs::kSearchProviderOverrides, overrides);
int version = TemplateURLPrepopulateData::GetDataVersion(prefs);
@@ -125,6 +123,58 @@ TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrefs) {
EXPECT_EQ("foi.com", t_urls[0]->favicon_url().host());
EXPECT_EQ(1u, t_urls[0]->input_encodings().size());
EXPECT_EQ(1001, t_urls[0]->prepopulate_id());
+ EXPECT_TRUE(t_urls[0]->suggestions_url().empty());
+ EXPECT_TRUE(t_urls[0]->instant_url().empty());
+ EXPECT_EQ(0u, t_urls[0]->alternate_urls().size());
+
+ // Test the optional settings too.
+ entry->SetString("suggest_url", "http://foo.com/suggest?q={searchTerms}");
+ entry->SetString("instant_url", "http://foo.com/instant?q={searchTerms}");
+ ListValue* alternate_urls = new ListValue;
+ alternate_urls->AppendString("http://foo.com/alternate?q={searchTerms}");
+ entry->Set("alternate_urls", alternate_urls);
+ overrides = new ListValue;
+ overrides->Append(entry->DeepCopy());
+ prefs->SetUserPref(prefs::kSearchProviderOverrides, overrides);
+
+ t_urls.clear();
+ TemplateURLPrepopulateData::GetPrepopulatedEngines(&profile, &t_urls.get(),
+ &default_index);
+ ASSERT_EQ(1u, t_urls.size());
+ EXPECT_EQ(ASCIIToUTF16("foo"), t_urls[0]->short_name());
+ EXPECT_EQ(ASCIIToUTF16("fook"), t_urls[0]->keyword());
+ EXPECT_EQ("foo.com", t_urls[0]->url_ref().GetHost());
+ EXPECT_EQ("foi.com", t_urls[0]->favicon_url().host());
+ EXPECT_EQ(1u, t_urls[0]->input_encodings().size());
+ EXPECT_EQ(1001, t_urls[0]->prepopulate_id());
+ EXPECT_EQ("http://foo.com/suggest?q={searchTerms}",
+ t_urls[0]->suggestions_url());
+ EXPECT_EQ("http://foo.com/instant?q={searchTerms}",
+ t_urls[0]->instant_url());
+ ASSERT_EQ(1u, t_urls[0]->alternate_urls().size());
+ EXPECT_EQ("http://foo.com/alternate?q={searchTerms}",
+ t_urls[0]->alternate_urls()[0]);
+
+ // Test that subsequent providers are loaded even if an intermediate
+ // provider has an incomplete configuration.
+ overrides = new ListValue;
+ overrides->Append(entry->DeepCopy());
+ entry->SetInteger("id", 1002);
+ entry->SetString("name", "bar");
+ entry->SetString("keyword", "bark");
+ entry->SetString("encoding", "");
+ overrides->Append(entry->DeepCopy());
+ entry->SetInteger("id", 1003);
+ entry->SetString("name", "baz");
+ entry->SetString("keyword", "bazk");
+ entry->SetString("encoding", "UTF-8");
+ overrides->Append(entry->DeepCopy());
+ prefs->SetUserPref(prefs::kSearchProviderOverrides, overrides);
+
+ t_urls.clear();
+ TemplateURLPrepopulateData::GetPrepopulatedEngines(&profile, &t_urls.get(),
+ &default_index);
+ EXPECT_EQ(2u, t_urls.size());
}
TEST(TemplateURLPrepopulateDataTest, GetEngineTypeBasic) {
« no previous file with comments | « chrome/browser/search_engines/template_url_prepopulate_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698