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

Side by Side Diff: chrome/browser/prefs/prefs_syncable_service_unittest.cc

Issue 444763005: Clear a preference when sync tries to delete a preference (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/prefs/pref_model_associator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "base/json/json_string_value_serializer.h" 6 #include "base/json/json_string_value_serializer.h"
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/prefs/scoped_user_pref_update.h" 9 #include "base/prefs/scoped_user_pref_update.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 InitWithSyncDataTakeOutput(syncer::SyncDataList(), &out); 686 InitWithSyncDataTakeOutput(syncer::SyncDataList(), &out);
687 687
688 EXPECT_TRUE(IsSynced(prefs::kHomePage)); 688 EXPECT_TRUE(IsSynced(prefs::kHomePage));
689 EXPECT_TRUE(pref->IsDefaultValue()); 689 EXPECT_TRUE(pref->IsDefaultValue());
690 EXPECT_FALSE(FindValue(prefs::kHomePage, out).get()); 690 EXPECT_FALSE(FindValue(prefs::kHomePage, out).get());
691 out.clear(); 691 out.clear();
692 692
693 // Switch kHomePage to managed and set a different value. 693 // Switch kHomePage to managed and set a different value.
694 base::StringValue managed_value("http://example.com/managed"); 694 base::StringValue managed_value("http://example.com/managed");
695 GetTestingPrefService()->SetManagedPref(prefs::kHomePage, 695 GetTestingPrefService()->SetManagedPref(prefs::kHomePage,
696 managed_value.DeepCopy()); 696 managed_value.DeepCopy());
697 // The pref value should be the one dictated by policy. 697 // The pref value should be the one dictated by policy.
698 EXPECT_TRUE(managed_value.Equals(&GetPreferenceValue(prefs::kHomePage))); 698 EXPECT_TRUE(managed_value.Equals(&GetPreferenceValue(prefs::kHomePage)));
699 EXPECT_FALSE(pref->IsDefaultValue()); 699 EXPECT_FALSE(pref->IsDefaultValue());
700 // There should be no synced value. 700 // There should be no synced value.
701 EXPECT_FALSE(FindValue(prefs::kHomePage, out).get()); 701 EXPECT_FALSE(FindValue(prefs::kHomePage, out).get());
702 // Switch kHomePage back to unmanaged. 702 // Switch kHomePage back to unmanaged.
703 GetTestingPrefService()->RemoveManagedPref(prefs::kHomePage); 703 GetTestingPrefService()->RemoveManagedPref(prefs::kHomePage);
704 // The original value should be picked up. 704 // The original value should be picked up.
705 EXPECT_TRUE(pref->IsDefaultValue()); 705 EXPECT_TRUE(pref->IsDefaultValue());
706 // There should still be no synced value. 706 // There should still be no synced value.
707 EXPECT_FALSE(FindValue(prefs::kHomePage, out).get()); 707 EXPECT_FALSE(FindValue(prefs::kHomePage, out).get());
708 } 708 }
709
710 TEST_F(PrefsSyncableServiceTest, DeletePreference) {
711 prefs_.SetString(prefs::kHomePage, kExampleUrl0);
712 const PrefService::Preference* pref =
713 prefs_.FindPreference(prefs::kHomePage);
714 EXPECT_FALSE(pref->IsDefaultValue());
715
716 InitWithNoSyncData();
717
718 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue());
719 syncer::SyncChangeList list;
720 list.push_back(MakeRemoteChange(
721 1, prefs::kHomePage, *null_value, SyncChange::ACTION_DELETE));
722 pref_sync_service_->ProcessSyncChanges(FROM_HERE, list);
723 EXPECT_TRUE(pref->IsDefaultValue());
724 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_model_associator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698