| 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* 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) {
|
| // First start off with a few entries and make sure we can set an unmanaged
|
| // default search provider.
|
|
|