| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() { | 196 ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() { |
| 197 Flush(); | 197 Flush(); |
| 198 DeviceSettingsService::Get()->UnsetSessionManager(); | 198 DeviceSettingsService::Get()->UnsetSessionManager(); |
| 199 DeviceSettingsService::Shutdown(); | 199 DeviceSettingsService::Shutdown(); |
| 200 } | 200 } |
| 201 | 201 |
| 202 DeviceSettingsTestBase::DeviceSettingsTestBase() | 202 DeviceSettingsTestBase::DeviceSettingsTestBase() |
| 203 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 203 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
| 204 user_manager_(new FakeChromeUserManager()), | 204 user_manager_(new FakeChromeUserManager()), |
| 205 user_manager_enabler_(user_manager_), | 205 user_manager_enabler_(user_manager_), |
| 206 owner_key_util_(new ownership::MockOwnerKeyUtil()) { | 206 owner_key_util_(new ownership::MockOwnerKeyUtil()), |
| 207 cros_settings_(&device_settings_service_) { |
| 207 OwnerSettingsServiceChromeOSFactory::SetDeviceSettingsServiceForTesting( | 208 OwnerSettingsServiceChromeOSFactory::SetDeviceSettingsServiceForTesting( |
| 208 &device_settings_service_); | 209 &device_settings_service_); |
| 209 OwnerSettingsServiceChromeOSFactory::GetInstance()->SetOwnerKeyUtilForTesting( | 210 OwnerSettingsServiceChromeOSFactory::GetInstance()->SetOwnerKeyUtilForTesting( |
| 210 owner_key_util_); | 211 owner_key_util_); |
| 212 OwnerSettingsServiceChromeOSFactory::SetCrosSettingsForTesting( |
| 213 &cros_settings_); |
| 211 } | 214 } |
| 212 | 215 |
| 213 DeviceSettingsTestBase::~DeviceSettingsTestBase() { | 216 DeviceSettingsTestBase::~DeviceSettingsTestBase() { |
| 214 base::RunLoop().RunUntilIdle(); | 217 base::RunLoop().RunUntilIdle(); |
| 215 } | 218 } |
| 216 | 219 |
| 217 void DeviceSettingsTestBase::SetUp() { | 220 void DeviceSettingsTestBase::SetUp() { |
| 218 // Initialize DBusThreadManager with a stub implementation. | 221 // Initialize DBusThreadManager with a stub implementation. |
| 219 dbus_setter_ = chromeos::DBusThreadManager::GetSetterForTesting(); | 222 dbus_setter_ = chromeos::DBusThreadManager::GetSetterForTesting(); |
| 220 | 223 |
| 221 base::RunLoop().RunUntilIdle(); | 224 base::RunLoop().RunUntilIdle(); |
| 222 | 225 |
| 223 device_policy_.payload().mutable_metrics_enabled()->set_metrics_enabled( | 226 device_policy_.payload().mutable_metrics_enabled()->set_metrics_enabled( |
| 224 false); | 227 false); |
| 225 owner_key_util_->SetPublicKeyFromPrivateKey(*device_policy_.GetSigningKey()); | 228 owner_key_util_->SetPublicKeyFromPrivateKey(*device_policy_.GetSigningKey()); |
| 226 device_policy_.Build(); | 229 device_policy_.Build(); |
| 227 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); | 230 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); |
| 228 device_settings_service_.SetSessionManager(&device_settings_test_helper_, | 231 device_settings_service_.SetSessionManager(&device_settings_test_helper_, |
| 229 owner_key_util_); | 232 owner_key_util_); |
| 230 profile_.reset(new TestingProfile()); | 233 profile_.reset(new TestingProfile()); |
| 231 } | 234 } |
| 232 | 235 |
| 233 void DeviceSettingsTestBase::TearDown() { | 236 void DeviceSettingsTestBase::TearDown() { |
| 237 OwnerSettingsServiceChromeOSFactory::SetCrosSettingsForTesting(nullptr); |
| 234 OwnerSettingsServiceChromeOSFactory::SetDeviceSettingsServiceForTesting(NULL); | 238 OwnerSettingsServiceChromeOSFactory::SetDeviceSettingsServiceForTesting(NULL); |
| 235 FlushDeviceSettings(); | 239 FlushDeviceSettings(); |
| 236 device_settings_service_.UnsetSessionManager(); | 240 device_settings_service_.UnsetSessionManager(); |
| 237 DBusThreadManager::Shutdown(); | 241 DBusThreadManager::Shutdown(); |
| 238 } | 242 } |
| 239 | 243 |
| 240 void DeviceSettingsTestBase::FlushDeviceSettings() { | 244 void DeviceSettingsTestBase::FlushDeviceSettings() { |
| 241 device_settings_test_helper_.Flush(); | 245 device_settings_test_helper_.Flush(); |
| 242 } | 246 } |
| 243 | 247 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 259 const_cast<user_manager::User*>(user)); | 263 const_cast<user_manager::User*>(user)); |
| 260 } | 264 } |
| 261 OwnerSettingsServiceChromeOS* service = | 265 OwnerSettingsServiceChromeOS* service = |
| 262 OwnerSettingsServiceChromeOSFactory::GetForBrowserContext(profile_.get()); | 266 OwnerSettingsServiceChromeOSFactory::GetForBrowserContext(profile_.get()); |
| 263 CHECK(service); | 267 CHECK(service); |
| 264 if (tpm_is_ready) | 268 if (tpm_is_ready) |
| 265 service->OnTPMTokenReady(true /* token is enabled */); | 269 service->OnTPMTokenReady(true /* token is enabled */); |
| 266 } | 270 } |
| 267 | 271 |
| 268 } // namespace chromeos | 272 } // namespace chromeos |
| OLD | NEW |