summaryrefslogtreecommitdiffstats
path: root/chrome/test/testing_pref_service.cc
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-21 13:54:08 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-21 13:54:08 +0000
commit74379bc51320fd98a47c98053a056b4ddd7271a7 (patch)
tree721fb4cbad36a304162745d8a0a5ee0930f054f0 /chrome/test/testing_pref_service.cc
parent7082b2329218da9a77fd6bc9587e86d0ed817196 (diff)
downloadchromium_src-74379bc51320fd98a47c98053a056b4ddd7271a7.zip
chromium_src-74379bc51320fd98a47c98053a056b4ddd7271a7.tar.gz
chromium_src-74379bc51320fd98a47c98053a056b4ddd7271a7.tar.bz2
Adjust preference sync code to only sync user modifiable preferences.
Switch to the new preference value source checkers in Preference. While at it, add a unit test and better test infrastructure for controlling preference values in tests. Convert existing unit tests where appropriate. BUG=48952 TEST=ProfileSyncServicePreferenceTest.ManagedPreferences Review URL: http://codereview.chromium.org/3051001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53179 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/testing_pref_service.cc')
-rw-r--r--chrome/test/testing_pref_service.cc60
1 files changed, 60 insertions, 0 deletions
diff --git a/chrome/test/testing_pref_service.cc b/chrome/test/testing_pref_service.cc
new file mode 100644
index 0000000..e6dde83
--- /dev/null
+++ b/chrome/test/testing_pref_service.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/test/testing_pref_service.h"
+
+#include "chrome/browser/dummy_pref_store.h"
+#include "chrome/browser/pref_value_store.h"
+
+TestingPrefService::TestingPrefService()
+ : PrefService(new PrefValueStore(
+ managed_prefs_ = new DummyPrefStore(),
+ NULL,
+ NULL,
+ user_prefs_ = new DummyPrefStore(),
+ NULL)) {
+}
+
+const Value* TestingPrefService::GetManagedPref(const wchar_t* path) {
+ return GetPref(managed_prefs_, path);
+}
+
+void TestingPrefService::SetManagedPref(const wchar_t* path, Value* value) {
+ SetPref(managed_prefs_, path, value);
+}
+
+void TestingPrefService::RemoveManagedPref(const wchar_t* path) {
+ RemovePref(managed_prefs_, path);
+}
+
+const Value* TestingPrefService::GetUserPref(const wchar_t* path) {
+ return GetPref(user_prefs_, path);
+}
+
+void TestingPrefService::SetUserPref(const wchar_t* path, Value* value) {
+ SetPref(user_prefs_, path, value);
+}
+
+void TestingPrefService::RemoveUserPref(const wchar_t* path) {
+ RemovePref(user_prefs_, path);
+}
+
+const Value* TestingPrefService::GetPref(PrefStore* pref_store,
+ const wchar_t* path) {
+ Value* result;
+ return pref_store->prefs()->Get(path, &result) ? result : NULL;
+}
+
+void TestingPrefService::SetPref(PrefStore* pref_store,
+ const wchar_t* path,
+ Value* value) {
+ pref_store->prefs()->Set(path, value);
+ FireObservers(path);
+}
+
+void TestingPrefService::RemovePref(PrefStore* pref_store,
+ const wchar_t* path) {
+ pref_store->prefs()->Remove(path, NULL);
+ FireObservers(path);
+}