| 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.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/settings/device_settings_service.h" | 10 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() { | 179 ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() { |
| 180 Flush(); | 180 Flush(); |
| 181 DeviceSettingsService::Get()->UnsetSessionManager(); | 181 DeviceSettingsService::Get()->UnsetSessionManager(); |
| 182 DeviceSettingsService::Shutdown(); | 182 DeviceSettingsService::Shutdown(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 DeviceSettingsTestBase::DeviceSettingsTestBase() | 185 DeviceSettingsTestBase::DeviceSettingsTestBase() |
| 186 : loop_(MessageLoop::TYPE_UI), | 186 : loop_(MessageLoop::TYPE_UI), |
| 187 ui_thread_(content::BrowserThread::UI, &loop_), | 187 ui_thread_(content::BrowserThread::UI, &loop_), |
| 188 file_thread_(content::BrowserThread::FILE, &loop_), | 188 file_thread_(content::BrowserThread::FILE, &loop_), |
| 189 owner_key_util_(new MockOwnerKeyUtil()) {} | 189 owner_key_util_(new MockOwnerKeyUtil()) { |
| 190 DeviceSettingsService::Initialize(); |
| 191 } |
| 190 | 192 |
| 191 DeviceSettingsTestBase::~DeviceSettingsTestBase() { | 193 DeviceSettingsTestBase::~DeviceSettingsTestBase() { |
| 192 base::RunLoop().RunUntilIdle(); | 194 base::RunLoop().RunUntilIdle(); |
| 195 DeviceSettingsService::Shutdown(); |
| 193 } | 196 } |
| 194 | 197 |
| 195 void DeviceSettingsTestBase::SetUp() { | 198 void DeviceSettingsTestBase::SetUp() { |
| 196 device_policy_.payload().mutable_metrics_enabled()->set_metrics_enabled( | 199 device_policy_.payload().mutable_metrics_enabled()->set_metrics_enabled( |
| 197 false); | 200 false); |
| 198 owner_key_util_->SetPublicKeyFromPrivateKey(device_policy_.signing_key()); | 201 owner_key_util_->SetPublicKeyFromPrivateKey(device_policy_.signing_key()); |
| 199 device_policy_.Build(); | 202 device_policy_.Build(); |
| 200 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); | 203 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); |
| 201 device_settings_service_.SetSessionManager(&device_settings_test_helper_, | 204 DeviceSettingsService::Get()->SetSessionManager(&device_settings_test_helper_, |
| 202 owner_key_util_); | 205 owner_key_util_); |
| 203 } | 206 } |
| 204 | 207 |
| 205 void DeviceSettingsTestBase::TearDown() { | 208 void DeviceSettingsTestBase::TearDown() { |
| 206 FlushDeviceSettings(); | 209 FlushDeviceSettings(); |
| 207 device_settings_service_.UnsetSessionManager(); | 210 DeviceSettingsService::Get()->UnsetSessionManager(); |
| 208 } | 211 } |
| 209 | 212 |
| 210 void DeviceSettingsTestBase::FlushDeviceSettings() { | 213 void DeviceSettingsTestBase::FlushDeviceSettings() { |
| 211 device_settings_test_helper_.Flush(); | 214 device_settings_test_helper_.Flush(); |
| 212 } | 215 } |
| 213 | 216 |
| 214 void DeviceSettingsTestBase::ReloadDeviceSettings() { | 217 void DeviceSettingsTestBase::ReloadDeviceSettings() { |
| 215 device_settings_service_.OwnerKeySet(true); | 218 DeviceSettingsService::Get()->OwnerKeySet(true); |
| 216 FlushDeviceSettings(); | 219 FlushDeviceSettings(); |
| 217 } | 220 } |
| 218 | 221 |
| 219 } // namespace chromeos | 222 } // namespace chromeos |
| OLD | NEW |