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

Unified Diff: chrome/browser/sync/profile_sync_service_preference_unittest.cc

Issue 3051001: Adjust preference sync code to only sync user modifiable preferences. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: separate out the download_manager_unittest.cc fixes Created 10 years, 5 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/sync/profile_sync_service_preference_unittest.cc
diff --git a/chrome/browser/sync/profile_sync_service_preference_unittest.cc b/chrome/browser/sync/profile_sync_service_preference_unittest.cc
index 6556c8384184b7a09448919d2aa4c661e635a308..94ae73572bbe16ddabe3d21472581a19794b7db4 100644
--- a/chrome/browser/sync/profile_sync_service_preference_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_preference_unittest.cc
@@ -173,7 +173,7 @@ class ProfileSyncServicePreferenceTest
friend class AddPreferenceEntriesTask;
scoped_ptr<TestingProfile> profile_;
- PrefService* prefs_;
+ TestingPrefService* prefs_;
PreferenceModelAssociator* model_associator_;
PreferenceChangeProcessor* change_processor_;
@@ -411,3 +411,35 @@ TEST_F(ProfileSyncServicePreferenceTest, UpdatedSyncNodeUnknownPreference) {
// Nothing interesting happens on the client when it gets an update
// of an unknown preference. We just should not crash.
}
+
+TEST_F(ProfileSyncServicePreferenceTest, ManagedPreferences) {
+ // Make the homepage preference managed.
+ scoped_ptr<Value> managed_value(
+ Value::CreateStringValue(L"http://example.com"));
+ prefs_->SetManagedPref(prefs::kHomePage, managed_value->DeepCopy());
+
+ CreateRootTask task(this, syncable::PREFERENCES);
+ ASSERT_TRUE(StartSyncService(&task, false));
+ ASSERT_TRUE(task.success());
+
+ // Changing the homepage preference should not sync anything.
+ scoped_ptr<Value> user_value(
+ Value::CreateStringValue(L"http://chromium..com"));
+ prefs_->SetUserPref(prefs::kHomePage, user_value->DeepCopy());
+ EXPECT_EQ(NULL, GetSyncedValue(prefs::kHomePage));
+
+ // An incoming sync transaction shouldn't change the user value.
+ scoped_ptr<Value> sync_value(
+ Value::CreateStringValue(L"http://crbug.com"));
+ int64 node_id = SetSyncedValue(prefs::kHomePage, *sync_value);
+ ASSERT_NE(node_id, sync_api::kInvalidId);
+ scoped_ptr<SyncManager::ChangeRecord> record(new SyncManager::ChangeRecord);
+ record->action = SyncManager::ChangeRecord::ACTION_UPDATE;
+ record->id = node_id;
+ {
+ sync_api::WriteTransaction trans(backend()->GetUserShareHandle());
+ change_processor_->ApplyChangesFromSyncModel(&trans, record.get(), 1);
+ }
+ EXPECT_TRUE(managed_value->Equals(prefs_->GetManagedPref(prefs::kHomePage)));
+ EXPECT_TRUE(user_value->Equals(prefs_->GetUserPref(prefs::kHomePage)));
+}
« no previous file with comments | « chrome/browser/sync/glue/preference_model_associator.cc ('k') | chrome/browser/tab_contents/web_contents_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698