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

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

Issue 268643002: Use the DefaultSearchManager as the exclusive authority on DSE, ignoring Web Data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore DSP origin change metric. Restore some naming and ordering. 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 d0ec2d936efd13c9cb4c38f552ed5d6365e63caf..0421f570a6458e3fdfd04846e1fda0cba5e2ceed 100644
--- a/chrome/browser/search_engines/template_url_service_sync_unittest.cc
+++ b/chrome/browser/search_engines/template_url_service_sync_unittest.cc
@@ -230,6 +230,7 @@ TemplateURLServiceSyncTest::TemplateURLServiceSyncTest()
sync_processor_.get())) {}
void TemplateURLServiceSyncTest::SetUp() {
+ TemplateURLService::set_fallback_search_engines_disabled();
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
@@ -1634,41 +1635,6 @@ TEST_F(TemplateURLServiceSyncTest, SyncedDefaultAlreadySetOnStartup) {
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) {
// First start off with a few entries and make sure we can set an unmanaged
// default search provider.
@@ -2249,3 +2215,25 @@ TEST_F(TemplateURLServiceSyncTest, MergeNonEditedPrepopulatedEngine) {
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));
+}

Powered by Google App Engine
This is Rietveld 408576698