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

Side by Side Diff: chrome/test/base/testing_pref_service.cc

Issue 8568019: Introduce per-tab preferences service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed ProfileSyncServicePreferenceTest tests Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/test/base/testing_pref_service.h" 5 #include "chrome/test/base/testing_pref_service.h"
6 6
7 #include "chrome/browser/policy/configuration_policy_pref_store.h" 7 #include "chrome/browser/policy/configuration_policy_pref_store.h"
8 #include "chrome/browser/prefs/browser_prefs.h" 8 #include "chrome/browser/prefs/browser_prefs.h"
9 #include "chrome/browser/prefs/command_line_pref_store.h" 9 #include "chrome/browser/prefs/command_line_pref_store.h"
10 #include "chrome/browser/prefs/default_pref_store.h" 10 #include "chrome/browser/prefs/default_pref_store.h"
11 #include "chrome/browser/prefs/pref_notifier.h" 11 #include "chrome/browser/prefs/pref_model_associator.h"
12 #include "chrome/browser/prefs/pref_notifier_impl.h"
12 #include "chrome/browser/prefs/pref_value_store.h" 13 #include "chrome/browser/prefs/pref_value_store.h"
13 #include "chrome/browser/prefs/testing_pref_store.h" 14 #include "chrome/browser/prefs/testing_pref_store.h"
14 #include "chrome/test/base/testing_browser_process.h" 15 #include "chrome/test/base/testing_browser_process.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 TestingPrefServiceBase::TestingPrefServiceBase( 18 TestingPrefServiceBase::TestingPrefServiceBase(
18 TestingPrefStore* managed_platform_prefs, 19 TestingPrefStore* managed_platform_prefs,
19 TestingPrefStore* user_prefs, 20 TestingPrefStore* user_prefs,
20 TestingPrefStore* recommended_platform_prefs) 21 TestingPrefStore* recommended_platform_prefs,
21 : PrefService(managed_platform_prefs, 22 DefaultPrefStore* default_store,
22 NULL, 23 PrefModelAssociator* pref_sync_associator,
23 NULL, 24 PrefNotifierImpl* pref_notifier)
24 NULL, 25 : PrefService(pref_notifier,
26 new PrefValueStore(
27 managed_platform_prefs,
28 NULL,
29 NULL,
30 NULL,
31 user_prefs,
32 recommended_platform_prefs,
33 NULL,
34 default_store,
35 pref_sync_associator,
36 pref_notifier),
25 user_prefs, 37 user_prefs,
26 recommended_platform_prefs, 38 default_store,
27 NULL, 39 pref_sync_associator,
28 new DefaultPrefStore(),
29 false), 40 false),
30 managed_platform_prefs_(managed_platform_prefs), 41 managed_platform_prefs_(managed_platform_prefs),
31 user_prefs_(user_prefs), 42 user_prefs_(user_prefs),
32 recommended_platform_prefs_(recommended_platform_prefs) { 43 recommended_platform_prefs_(recommended_platform_prefs) {
33 } 44 }
34 45
35 TestingPrefServiceBase::~TestingPrefServiceBase() { 46 TestingPrefServiceBase::~TestingPrefServiceBase() {
36 } 47 }
37 48
38 const Value* TestingPrefServiceBase::GetManagedPref(const char* path) const { 49 const Value* TestingPrefServiceBase::GetManagedPref(const char* path) const {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 97 }
87 98
88 void TestingPrefServiceBase::RemovePref(TestingPrefStore* pref_store, 99 void TestingPrefServiceBase::RemovePref(TestingPrefStore* pref_store,
89 const char* path) { 100 const char* path) {
90 pref_store->RemoveValue(path); 101 pref_store->RemoveValue(path);
91 } 102 }
92 103
93 TestingPrefService::TestingPrefService() 104 TestingPrefService::TestingPrefService()
94 : TestingPrefServiceBase(new TestingPrefStore(), 105 : TestingPrefServiceBase(new TestingPrefStore(),
95 new TestingPrefStore(), 106 new TestingPrefStore(),
96 new TestingPrefStore()) { 107 new TestingPrefStore(),
108 new DefaultPrefStore(),
109 new PrefModelAssociator(),
110 new PrefNotifierImpl()) {
97 } 111 }
98 112
99 TestingPrefService::~TestingPrefService() { 113 TestingPrefService::~TestingPrefService() {
100 } 114 }
101 115
102 ScopedTestingLocalState::ScopedTestingLocalState( 116 ScopedTestingLocalState::ScopedTestingLocalState(
103 TestingBrowserProcess* browser_process) 117 TestingBrowserProcess* browser_process)
104 : browser_process_(browser_process) { 118 : browser_process_(browser_process) {
105 browser::RegisterLocalState(&local_state_); 119 browser::RegisterLocalState(&local_state_);
106 EXPECT_FALSE(browser_process->local_state()); 120 EXPECT_FALSE(browser_process->local_state());
107 browser_process->SetLocalState(&local_state_); 121 browser_process->SetLocalState(&local_state_);
108 } 122 }
109 123
110 ScopedTestingLocalState::~ScopedTestingLocalState() { 124 ScopedTestingLocalState::~ScopedTestingLocalState() {
111 EXPECT_EQ(&local_state_, browser_process_->local_state()); 125 EXPECT_EQ(&local_state_, browser_process_->local_state());
112 browser_process_->SetLocalState(NULL); 126 browser_process_->SetLocalState(NULL);
113 } 127 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698