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

Side by Side Diff: chrome/browser/chromeos/settings/device_settings_test_helper.cc

Issue 14200028: Make CrosSettings and DeviceSettingsService non Lazy instances (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/chromeos/settings/device_settings_test_helper.h" 5 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/threading/sequenced_worker_pool.h" 9 #include "base/threading/sequenced_worker_pool.h"
10 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 10 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 device_local_account_policy_[account_id].policy_blob_ = policy_blob; 160 device_local_account_policy_[account_id].policy_blob_ = policy_blob;
161 device_local_account_policy_[account_id].store_callbacks_.push_back(callback); 161 device_local_account_policy_[account_id].store_callbacks_.push_back(callback);
162 } 162 }
163 163
164 DeviceSettingsTestHelper::PolicyState::PolicyState() 164 DeviceSettingsTestHelper::PolicyState::PolicyState()
165 : store_result_(true) {} 165 : store_result_(true) {}
166 166
167 DeviceSettingsTestHelper::PolicyState::~PolicyState() {} 167 DeviceSettingsTestHelper::PolicyState::~PolicyState() {}
168 168
169 ScopedDeviceSettingsTestHelper::ScopedDeviceSettingsTestHelper() { 169 ScopedDeviceSettingsTestHelper::ScopedDeviceSettingsTestHelper() {
170 DeviceSettingsService::Get()->Initialize(this, new MockOwnerKeyUtil()); 170 DeviceSettingsService::Initialize();
171 DeviceSettingsService::Get()->SetSessionManager(this, new MockOwnerKeyUtil());
171 DeviceSettingsService::Get()->Load(); 172 DeviceSettingsService::Get()->Load();
172 Flush(); 173 Flush();
173 } 174 }
174 175
175 ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() { 176 ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() {
176 Flush(); 177 Flush();
177 DeviceSettingsService::Get()->Shutdown(); 178 DeviceSettingsService::Get()->UnsetSessionManager();
179 DeviceSettingsService::Shutdown();
178 } 180 }
179 181
180 DeviceSettingsTestBase::DeviceSettingsTestBase() 182 DeviceSettingsTestBase::DeviceSettingsTestBase()
181 : loop_(MessageLoop::TYPE_UI), 183 : loop_(MessageLoop::TYPE_UI),
182 ui_thread_(content::BrowserThread::UI, &loop_), 184 ui_thread_(content::BrowserThread::UI, &loop_),
183 file_thread_(content::BrowserThread::FILE, &loop_), 185 file_thread_(content::BrowserThread::FILE, &loop_),
184 owner_key_util_(new MockOwnerKeyUtil()) {} 186 owner_key_util_(new MockOwnerKeyUtil()) {}
185 187
186 DeviceSettingsTestBase::~DeviceSettingsTestBase() { 188 DeviceSettingsTestBase::~DeviceSettingsTestBase() {
187 base::RunLoop().RunUntilIdle(); 189 base::RunLoop().RunUntilIdle();
188 } 190 }
189 191
190 void DeviceSettingsTestBase::SetUp() { 192 void DeviceSettingsTestBase::SetUp() {
191 device_policy_.payload().mutable_metrics_enabled()->set_metrics_enabled( 193 device_policy_.payload().mutable_metrics_enabled()->set_metrics_enabled(
192 false); 194 false);
193 owner_key_util_->SetPublicKeyFromPrivateKey(device_policy_.signing_key()); 195 owner_key_util_->SetPublicKeyFromPrivateKey(device_policy_.signing_key());
194 device_policy_.Build(); 196 device_policy_.Build();
195 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); 197 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob());
196 device_settings_service_.Initialize(&device_settings_test_helper_, 198 device_settings_service_.SetSessionManager(&device_settings_test_helper_,
197 owner_key_util_); 199 owner_key_util_);
198 } 200 }
199 201
200 void DeviceSettingsTestBase::TearDown() { 202 void DeviceSettingsTestBase::TearDown() {
201 FlushDeviceSettings(); 203 FlushDeviceSettings();
202 device_settings_service_.Shutdown(); 204 device_settings_service_.UnsetSessionManager();
203 } 205 }
204 206
205 void DeviceSettingsTestBase::FlushDeviceSettings() { 207 void DeviceSettingsTestBase::FlushDeviceSettings() {
206 device_settings_test_helper_.Flush(); 208 device_settings_test_helper_.Flush();
207 } 209 }
208 210
209 void DeviceSettingsTestBase::ReloadDeviceSettings() { 211 void DeviceSettingsTestBase::ReloadDeviceSettings() {
210 device_settings_service_.OwnerKeySet(true); 212 device_settings_service_.OwnerKeySet(true);
211 FlushDeviceSettings(); 213 FlushDeviceSettings();
212 } 214 }
213 215
214 } // namespace chromeos 216 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/settings/device_settings_test_helper.h ('k') | chrome/browser/extensions/extension_service_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698