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

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

Issue 10831338: Ensure that MergeDataAndStartSyncing considers already synced entries when setting the synced DSP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: check once instead of per processed turl Created 8 years, 4 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_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 151691)
+++ chrome/browser/search_engines/template_url_service_sync_unittest.cc (working copy)
@@ -1570,6 +1570,40 @@
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()->SetDefaultSearchProvider(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* expected_default = model()->GetDefaultSearchProvider();
Nicolas Zea 2012/08/16 20:03:03 nit: this isn't the expected, but the current righ
SteveT 2012/08/16 20:24:00 Right, renamed this variable.
+ ASSERT_TRUE(expected_default);
+ EXPECT_EQ("key2", expected_default->sync_guid());
+ EXPECT_EQ(ASCIIToUTF16("key2"), expected_default->keyword());
+}
+
TEST_F(TemplateURLServiceSyncTest, SyncWithManagedDefaultSearch) {
// First start off with a few entries and make sure we can set an unmanaged
// default search provider.
« 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