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

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

Issue 8689007: Defend against deleting the default search provider when merging duplicate TURLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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_service.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_service_sync_unittest.cc
===================================================================
--- chrome/browser/search_engines/template_url_service_sync_unittest.cc (revision 111543)
+++ chrome/browser/search_engines/template_url_service_sync_unittest.cc (working copy)
@@ -1275,3 +1275,23 @@
EXPECT_EQ(expected_default, model()->GetDefaultSearchProvider());
}
+
+TEST_F(TemplateURLServiceSyncTest, SyncMergeDeletesDefault) {
+ // If the value from Sync is a duplicate of the local default and is newer, it
+ // should safely replace the local value and set as the new default.
+ TemplateURL* default_turl =
+ CreateTestTemplateURL("key1", "http://key1.com", "whateverguid", 10);
+ model()->Add(default_turl);
+ model()->SetDefaultSearchProvider(default_turl);
+
+ // The key1 entry should be a duplicate of the default.
+ model()->MergeDataAndStartSyncing(
+ syncable::SEARCH_ENGINES,
+ CreateInitialSyncData(),
+ processor());
+
+ EXPECT_EQ(3U, model()->GetAllSyncData(syncable::SEARCH_ENGINES).size());
+ EXPECT_FALSE(model()->GetTemplateURLForGUID("whateverguid"));
+ EXPECT_EQ(model()->GetDefaultSearchProvider(),
+ model()->GetTemplateURLForGUID("key1"));
+}
« no previous file with comments | « chrome/browser/search_engines/template_url_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698