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.h" | 10 #include "chrome/browser/chromeos/ownership/owner_settings_service.h" |
11 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h" | 11 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h" |
12 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 12 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
13 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 13 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
14 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 14 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
15 #include "chrome/browser/chromeos/settings/mock_owner_key_util.h" | 15 #include "chrome/browser/chromeos/settings/mock_owner_key_util.h" |
16 #include "chrome/test/base/testing_browser_process.h" | 16 #include "chrome/test/base/testing_browser_process.h" |
17 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
18 #include "chromeos/dbus/dbus_thread_manager.h" | 18 #include "chromeos/dbus/dbus_thread_manager.h" |
19 #include "chromeos/dbus/fake_dbus_thread_manager.h" | |
20 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
21 | 20 |
22 namespace chromeos { | 21 namespace chromeos { |
23 | 22 |
24 DeviceSettingsTestHelper::DeviceSettingsTestHelper() {} | 23 DeviceSettingsTestHelper::DeviceSettingsTestHelper() {} |
25 | 24 |
26 DeviceSettingsTestHelper::~DeviceSettingsTestHelper() {} | 25 DeviceSettingsTestHelper::~DeviceSettingsTestHelper() {} |
27 | 26 |
28 void DeviceSettingsTestHelper::FlushLoops() { | 27 void DeviceSettingsTestHelper::FlushLoops() { |
29 // DeviceSettingsService may trigger operations that hop back and forth | 28 // DeviceSettingsService may trigger operations that hop back and forth |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 198 |
200 ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() { | 199 ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() { |
201 Flush(); | 200 Flush(); |
202 DeviceSettingsService::Get()->UnsetSessionManager(); | 201 DeviceSettingsService::Get()->UnsetSessionManager(); |
203 DeviceSettingsService::Shutdown(); | 202 DeviceSettingsService::Shutdown(); |
204 } | 203 } |
205 | 204 |
206 DeviceSettingsTestBase::DeviceSettingsTestBase() | 205 DeviceSettingsTestBase::DeviceSettingsTestBase() |
207 : user_manager_(new FakeUserManager()), | 206 : user_manager_(new FakeUserManager()), |
208 user_manager_enabler_(user_manager_), | 207 user_manager_enabler_(user_manager_), |
209 owner_key_util_(new MockOwnerKeyUtil()), | 208 owner_key_util_(new MockOwnerKeyUtil()) { |
210 fake_dbus_thread_manager_(new FakeDBusThreadManager()) { | |
211 } | 209 } |
212 | 210 |
213 DeviceSettingsTestBase::~DeviceSettingsTestBase() { | 211 DeviceSettingsTestBase::~DeviceSettingsTestBase() { |
214 base::RunLoop().RunUntilIdle(); | 212 base::RunLoop().RunUntilIdle(); |
215 } | 213 } |
216 | 214 |
217 void DeviceSettingsTestBase::SetUp() { | 215 void DeviceSettingsTestBase::SetUp() { |
218 // Initialize DBusThreadManager with a stub implementation. | 216 // Initialize DBusThreadManager with a stub implementation. |
219 chromeos::DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager_); | 217 dbus_setter_ = chromeos::DBusThreadManager::GetSetterForTesting(); |
220 | 218 |
221 base::RunLoop().RunUntilIdle(); | 219 base::RunLoop().RunUntilIdle(); |
222 | 220 |
223 device_policy_.payload().mutable_metrics_enabled()->set_metrics_enabled( | 221 device_policy_.payload().mutable_metrics_enabled()->set_metrics_enabled( |
224 false); | 222 false); |
225 owner_key_util_->SetPublicKeyFromPrivateKey(*device_policy_.GetSigningKey()); | 223 owner_key_util_->SetPublicKeyFromPrivateKey(*device_policy_.GetSigningKey()); |
226 device_policy_.Build(); | 224 device_policy_.Build(); |
227 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); | 225 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); |
228 device_settings_service_.SetSessionManager(&device_settings_test_helper_, | 226 device_settings_service_.SetSessionManager(&device_settings_test_helper_, |
229 owner_key_util_); | 227 owner_key_util_); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 profile_.get()); | 259 profile_.get()); |
262 } | 260 } |
263 OwnerSettingsService* service = | 261 OwnerSettingsService* service = |
264 OwnerSettingsServiceFactory::GetForProfile(profile_.get()); | 262 OwnerSettingsServiceFactory::GetForProfile(profile_.get()); |
265 CHECK(service); | 263 CHECK(service); |
266 if (tpm_is_ready) | 264 if (tpm_is_ready) |
267 service->OnTPMTokenReady(); | 265 service->OnTPMTokenReady(); |
268 } | 266 } |
269 | 267 |
270 } // namespace chromeos | 268 } // namespace chromeos |
OLD | NEW |