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

Unified 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: Fix LoginUtilsTest 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/settings/device_settings_test_helper.cc
diff --git a/chrome/browser/chromeos/settings/device_settings_test_helper.cc b/chrome/browser/chromeos/settings/device_settings_test_helper.cc
index 664e58cad9efa0e3b92e2ae26887ddde8b1940ec..e3cf1face7206f64f79534147f7ededbffb83eb8 100644
--- a/chrome/browser/chromeos/settings/device_settings_test_helper.cc
+++ b/chrome/browser/chromeos/settings/device_settings_test_helper.cc
@@ -14,9 +14,15 @@
namespace chromeos {
-DeviceSettingsTestHelper::DeviceSettingsTestHelper() {}
+DeviceSettingsTestHelper::DeviceSettingsTestHelper() {
+ // DeviceSettingsTestHelper is used both by browser tests (where CrosSettings
+ // is already initialized) and unit tests, where it is not.
+ if (!CrosSettings::IsInitialized())
+ test_cros_settings_.reset(new ScopedTestCrosSettings);
+}
-DeviceSettingsTestHelper::~DeviceSettingsTestHelper() {}
+DeviceSettingsTestHelper::~DeviceSettingsTestHelper() {
+}
void DeviceSettingsTestHelper::FlushLoops() {
// DeviceSettingsService may trigger operations that hop back and forth
@@ -167,21 +173,24 @@ DeviceSettingsTestHelper::PolicyState::PolicyState()
DeviceSettingsTestHelper::PolicyState::~PolicyState() {}
ScopedDeviceSettingsTestHelper::ScopedDeviceSettingsTestHelper() {
- DeviceSettingsService::Get()->Initialize(this, new MockOwnerKeyUtil());
+ DeviceSettingsService::Get()->InitializeSessionManager(
+ this, new MockOwnerKeyUtil());
DeviceSettingsService::Get()->Load();
Flush();
}
ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() {
Flush();
- DeviceSettingsService::Get()->Shutdown();
+ DeviceSettingsService::Get()->ShutdownSessionManager();
}
DeviceSettingsTestBase::DeviceSettingsTestBase()
: loop_(MessageLoop::TYPE_UI),
ui_thread_(content::BrowserThread::UI, &loop_),
file_thread_(content::BrowserThread::FILE, &loop_),
- owner_key_util_(new MockOwnerKeyUtil()) {}
+ owner_key_util_(new MockOwnerKeyUtil()),
+ device_settings_service_(DeviceSettingsService::Get()) {
+}
DeviceSettingsTestBase::~DeviceSettingsTestBase() {
base::RunLoop().RunUntilIdle();
@@ -193,13 +202,14 @@ void DeviceSettingsTestBase::SetUp() {
owner_key_util_->SetPublicKeyFromPrivateKey(device_policy_.signing_key());
device_policy_.Build();
device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob());
- device_settings_service_.Initialize(&device_settings_test_helper_,
- owner_key_util_);
+ device_settings_service_->InitializeSessionManager(
+ &device_settings_test_helper_,
+ owner_key_util_);
}
void DeviceSettingsTestBase::TearDown() {
FlushDeviceSettings();
- device_settings_service_.Shutdown();
+ device_settings_service_->ShutdownSessionManager();
}
void DeviceSettingsTestBase::FlushDeviceSettings() {
@@ -207,7 +217,7 @@ void DeviceSettingsTestBase::FlushDeviceSettings() {
}
void DeviceSettingsTestBase::ReloadDeviceSettings() {
- device_settings_service_.OwnerKeySet(true);
+ device_settings_service_->OwnerKeySet(true);
FlushDeviceSettings();
}

Powered by Google App Engine
This is Rietveld 408576698