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

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

Issue 15572002: Implemented 'Reset Search engines' feature. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merge with trunk + Peter's comments Created 7 years, 7 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
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 a11adf36d3779a27de7c0392b95b3feea5359440..342f10fae62a35d6323f7d936742b5ad4dbe2655 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
@@ -6,6 +6,7 @@
#include "base/files/scoped_temp_dir.h"
#include "base/memory/scoped_vector.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/search_engines/prepopulated_engines.h"
#include "chrome/browser/search_engines/search_terms_data.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
@@ -181,6 +182,52 @@ TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrefs) {
EXPECT_EQ(2u, t_urls.size());
}
+TEST(TemplateURLPrepopulateDataTest, ClearProvidersFromPrefs) {
+ TestingProfile profile;
+ TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService();
+ prefs->SetUserPref(prefs::kSearchProviderOverridesVersion,
+ Value::CreateIntegerValue(1));
+ ListValue* overrides = new ListValue;
+ 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("encoding", "UTF-8");
+ entry->SetInteger("id", 1001);
+ overrides->Append(entry);
+ prefs->SetUserPref(prefs::kSearchProviderOverrides, overrides);
+
+ int version = TemplateURLPrepopulateData::GetDataVersion(prefs);
+ EXPECT_EQ(1, version);
+
+ // This call removes the above search engine.
+ TemplateURLPrepopulateData::ClearPrepopulatedEnginesInPrefs(&profile);
+
+ version = TemplateURLPrepopulateData::GetDataVersion(prefs);
+ EXPECT_EQ(TemplateURLPrepopulateData::kCurrentDataVersion, version);
+
+ ScopedVector<TemplateURL> t_urls;
+ size_t default_index;
+ TemplateURLPrepopulateData::GetPrepopulatedEngines(&profile, &t_urls.get(),
+ &default_index);
+ ASSERT_FALSE(t_urls.empty());
+ for (size_t i = 0; i < t_urls.size(); ++i) {
+ EXPECT_NE(ASCIIToUTF16("foo"), t_urls[i]->short_name());
+ EXPECT_NE(ASCIIToUTF16("fook"), t_urls[i]->keyword());
+ EXPECT_NE("foi.com", t_urls[i]->favicon_url().host());
+ EXPECT_NE("foo.com", t_urls[i]->url_ref().GetHost());
+ EXPECT_NE(1001, t_urls[i]->prepopulate_id());
+ }
+ // Ensures the default URL is Google and has the optional fields filled.
+ EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name());
+ EXPECT_FALSE(t_urls[default_index]->suggestions_url().empty());
+ EXPECT_FALSE(t_urls[default_index]->instant_url().empty());
+ EXPECT_EQ(SEARCH_ENGINE_GOOGLE,
+ TemplateURLPrepopulateData::GetEngineType(t_urls[default_index]->url()));
+}
+
// Verifies that built-in search providers are processed correctly.
TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrepopulated) {
// Use United States.
« no previous file with comments | « chrome/browser/search_engines/template_url_prepopulate_data.cc ('k') | chrome/browser/search_engines/template_url_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698