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

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

Issue 280113002: Revert of Use the DefaultSearchManager as the exclusive authority on DSE, ignoring Web Data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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_service_sync_unittest.cc
diff --git a/chrome/browser/search_engines/template_url_service_sync_unittest.cc b/chrome/browser/search_engines/template_url_service_sync_unittest.cc
index 60a18ba0042b2fcb8a7ee549fffd16bf19dd0c0c..d0ec2d936efd13c9cb4c38f552ed5d6365e63caf 100644
--- a/chrome/browser/search_engines/template_url_service_sync_unittest.cc
+++ b/chrome/browser/search_engines/template_url_service_sync_unittest.cc
@@ -230,7 +230,6 @@
sync_processor_.get())) {}
void TemplateURLServiceSyncTest::SetUp() {
- TemplateURLService::set_fallback_search_engines_disabled(true);
test_util_a_.SetUp();
// Use ChangeToLoadState() instead of VerifyLoad() so we don't actually pull
// in the prepopulate data, which the sync tests don't care about (and would
@@ -245,7 +244,6 @@
void TemplateURLServiceSyncTest::TearDown() {
test_util_a_.TearDown();
- TemplateURLService::set_fallback_search_engines_disabled(false);
}
scoped_ptr<syncer::SyncChangeProcessor>
@@ -1634,6 +1632,41 @@
// Ensure that the new entries were added and the default has not changed.
EXPECT_EQ(4U, model()->GetAllSyncData(syncer::SEARCH_ENGINES).size());
ASSERT_EQ(default_search, model()->GetDefaultSearchProvider());
+}
+
+TEST_F(TemplateURLServiceSyncTest, NewDefaultIsAlreadySynced) {
+ // Ensure that if the synced DSP pref changed to another synced entry (as
+ // opposed to coming in as a new entry), it gets reset correctly.
+ // Start by setting kSyncedDefaultSearchProviderGUID to the entry that should
+ // end up as the default. Note that this must be done before the initial
+ // entries are added as otherwise this call will set the DSP immediately.
+ profile_a()->GetTestingPrefService()->SetString(
+ prefs::kSyncedDefaultSearchProviderGUID, "key2");
+
+ syncer::SyncDataList initial_data = CreateInitialSyncData();
+ // Ensure that our candidate default supports replacement.
+ scoped_ptr<TemplateURL> turl(CreateTestTemplateURL(ASCIIToUTF16("key2"),
+ "http://key2.com/{searchTerms}", "key2", 90));
+ initial_data[1] = TemplateURLService::CreateSyncDataFromTemplateURL(*turl);
+ for (syncer::SyncDataList::const_iterator iter = initial_data.begin();
+ iter != initial_data.end(); ++iter) {
+ TemplateURL* converted = Deserialize(*iter);
+ model()->Add(converted);
+ }
+
+ // Set the initial default to something other than the desired default.
+ model()->SetUserSelectedDefaultSearchProvider(
+ model()->GetTemplateURLForGUID("key1"));
+
+ // Merge in the same data (i.e. already synced entries).
+ model()->MergeDataAndStartSyncing(syncer::SEARCH_ENGINES, initial_data,
+ PassProcessor(), CreateAndPassSyncErrorFactory());
+
+ EXPECT_EQ(3U, model()->GetAllSyncData(syncer::SEARCH_ENGINES).size());
+ TemplateURL* current_default = model()->GetDefaultSearchProvider();
+ ASSERT_TRUE(current_default);
+ EXPECT_EQ("key2", current_default->sync_guid());
+ EXPECT_EQ(ASCIIToUTF16("key2"), current_default->keyword());
}
TEST_F(TemplateURLServiceSyncTest, SyncWithManagedDefaultSearch) {
@@ -2216,25 +2249,3 @@
EXPECT_EQ(default_turl->short_name, result_turl->short_name());
EXPECT_EQ(default_turl->url(), result_turl->url());
}
-
-TEST_F(TemplateURLServiceSyncTest, GUIDUpdatedOnDefaultSearchChange) {
- const char kGUID[] = "initdefault";
- model()->Add(CreateTestTemplateURL(ASCIIToUTF16("what"),
- "http://thewhat.com/{searchTerms}",
- kGUID));
- model()->SetUserSelectedDefaultSearchProvider(
- model()->GetTemplateURLForGUID(kGUID));
-
- const TemplateURL* default_search = model()->GetDefaultSearchProvider();
- ASSERT_TRUE(default_search);
-
- const char kNewGUID[] = "newdefault";
- model()->Add(CreateTestTemplateURL(ASCIIToUTF16("what"),
- "http://thewhat.com/{searchTerms}",
- kNewGUID));
- model()->SetUserSelectedDefaultSearchProvider(
- model()->GetTemplateURLForGUID(kNewGUID));
-
- EXPECT_EQ(kNewGUID, profile_a()->GetTestingPrefService()->GetString(
- prefs::kSyncedDefaultSearchProviderGUID));
-}
« no previous file with comments | « chrome/browser/search_engines/template_url_service.cc ('k') | chrome/browser/search_engines/template_url_service_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698