OLD | NEW |
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/message_loop.h" | 7 #include "base/message_loop/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/ownership/owner_settings_service_chromeos.h" | 10 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() { | 190 ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() { |
191 Flush(); | 191 Flush(); |
192 DeviceSettingsService::Get()->UnsetSessionManager(); | 192 DeviceSettingsService::Get()->UnsetSessionManager(); |
193 DeviceSettingsService::Shutdown(); | 193 DeviceSettingsService::Shutdown(); |
194 } | 194 } |
195 | 195 |
196 DeviceSettingsTestBase::DeviceSettingsTestBase() | 196 DeviceSettingsTestBase::DeviceSettingsTestBase() |
197 : user_manager_(new FakeUserManager()), | 197 : user_manager_(new FakeUserManager()), |
198 user_manager_enabler_(user_manager_), | 198 user_manager_enabler_(user_manager_), |
199 owner_key_util_(new ownership::MockOwnerKeyUtil()) { | 199 owner_key_util_(new ownership::MockOwnerKeyUtil()) { |
| 200 OwnerSettingsServiceChromeOSFactory::SetDeviceSettingsServiceForTesting( |
| 201 &device_settings_service_); |
200 OwnerSettingsServiceChromeOSFactory::GetInstance()->SetOwnerKeyUtilForTesting( | 202 OwnerSettingsServiceChromeOSFactory::GetInstance()->SetOwnerKeyUtilForTesting( |
201 owner_key_util_); | 203 owner_key_util_); |
202 } | 204 } |
203 | 205 |
204 DeviceSettingsTestBase::~DeviceSettingsTestBase() { | 206 DeviceSettingsTestBase::~DeviceSettingsTestBase() { |
205 base::RunLoop().RunUntilIdle(); | 207 base::RunLoop().RunUntilIdle(); |
206 } | 208 } |
207 | 209 |
208 void DeviceSettingsTestBase::SetUp() { | 210 void DeviceSettingsTestBase::SetUp() { |
209 // Initialize DBusThreadManager with a stub implementation. | 211 // Initialize DBusThreadManager with a stub implementation. |
210 dbus_setter_ = chromeos::DBusThreadManager::GetSetterForTesting(); | 212 dbus_setter_ = chromeos::DBusThreadManager::GetSetterForTesting(); |
211 | 213 |
212 base::RunLoop().RunUntilIdle(); | 214 base::RunLoop().RunUntilIdle(); |
213 | 215 |
214 device_policy_.payload().mutable_metrics_enabled()->set_metrics_enabled( | 216 device_policy_.payload().mutable_metrics_enabled()->set_metrics_enabled( |
215 false); | 217 false); |
216 owner_key_util_->SetPublicKeyFromPrivateKey(*device_policy_.GetSigningKey()); | 218 owner_key_util_->SetPublicKeyFromPrivateKey(*device_policy_.GetSigningKey()); |
217 device_policy_.Build(); | 219 device_policy_.Build(); |
218 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); | 220 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); |
219 device_settings_service_.SetSessionManager(&device_settings_test_helper_, | 221 device_settings_service_.SetSessionManager(&device_settings_test_helper_, |
220 owner_key_util_); | 222 owner_key_util_); |
221 OwnerSettingsServiceChromeOS::SetDeviceSettingsServiceForTesting( | |
222 &device_settings_service_); | |
223 profile_.reset(new TestingProfile()); | 223 profile_.reset(new TestingProfile()); |
224 } | 224 } |
225 | 225 |
226 void DeviceSettingsTestBase::TearDown() { | 226 void DeviceSettingsTestBase::TearDown() { |
227 OwnerSettingsServiceChromeOS::SetDeviceSettingsServiceForTesting(NULL); | 227 OwnerSettingsServiceChromeOSFactory::SetDeviceSettingsServiceForTesting(NULL); |
228 FlushDeviceSettings(); | 228 FlushDeviceSettings(); |
229 device_settings_service_.UnsetSessionManager(); | 229 device_settings_service_.UnsetSessionManager(); |
230 DBusThreadManager::Shutdown(); | 230 DBusThreadManager::Shutdown(); |
231 } | 231 } |
232 | 232 |
233 void DeviceSettingsTestBase::FlushDeviceSettings() { | 233 void DeviceSettingsTestBase::FlushDeviceSettings() { |
234 device_settings_test_helper_.Flush(); | 234 device_settings_test_helper_.Flush(); |
235 } | 235 } |
236 | 236 |
237 void DeviceSettingsTestBase::ReloadDeviceSettings() { | 237 void DeviceSettingsTestBase::ReloadDeviceSettings() { |
(...skipping 12 matching lines...) Expand all Loading... |
250 profile_.get()); | 250 profile_.get()); |
251 } | 251 } |
252 OwnerSettingsServiceChromeOS* service = | 252 OwnerSettingsServiceChromeOS* service = |
253 OwnerSettingsServiceChromeOSFactory::GetForProfile(profile_.get()); | 253 OwnerSettingsServiceChromeOSFactory::GetForProfile(profile_.get()); |
254 CHECK(service); | 254 CHECK(service); |
255 if (tpm_is_ready) | 255 if (tpm_is_ready) |
256 service->OnTPMTokenReady(true /* token is enabled */); | 256 service->OnTPMTokenReady(true /* token is enabled */); |
257 } | 257 } |
258 | 258 |
259 } // namespace chromeos | 259 } // namespace chromeos |
OLD | NEW |