Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/settings/settings_provider_test_base.h" | |
| 6 | |
| 7 #include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h" | |
| 8 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 | |
| 11 namespace chromeos { | |
| 12 | |
| 13 SettingsProviderTestBase::SettingsProviderTestBase() { | |
| 14 if (!DeviceSettingsService::IsInitialized()) { | |
|
bartfab (slow)
2015/03/31 14:12:41
Nit: #include "chrome/browser/chromeos/settings/de
| |
| 15 test_device_settings_service_.reset(new ScopedTestDeviceSettingsService()); | |
| 16 test_cros_settings_.reset(new ScopedTestCrosSettings()); | |
| 17 } | |
| 18 } | |
| 19 | |
| 20 SettingsProviderTestBase::SettingsProviderTestBase( | |
| 21 bool create_settings_service) { | |
| 22 if (create_settings_service && !DeviceSettingsService::IsInitialized()) { | |
| 23 test_device_settings_service_.reset(new ScopedTestDeviceSettingsService()); | |
|
bartfab (slow)
2015/03/31 14:12:40
Nit: Move this common code out to a helper method.
| |
| 24 test_cros_settings_.reset(new ScopedTestCrosSettings()); | |
| 25 } | |
| 26 } | |
| 27 | |
| 28 SettingsProviderTestBase::~SettingsProviderTestBase() { | |
| 29 } | |
| 30 | |
| 31 void SettingsProviderTestBase::ReplaceProvider(const std::string& path) { | |
| 32 // Swap out the DeviceSettingsProvider with our settings provider so we can | |
| 33 // set values for the specified path. | |
| 34 CrosSettings* const cros_settings = CrosSettings::Get(); | |
| 35 device_settings_provider_ = cros_settings->GetProvider(path); | |
|
bartfab (slow)
2015/03/31 14:12:40
Nit: #include "chromeos/settings/cros_settings_pro
| |
| 36 EXPECT_TRUE(device_settings_provider_); | |
| 37 EXPECT_TRUE(cros_settings->RemoveSettingsProvider(device_settings_provider_)); | |
| 38 cros_settings->AddSettingsProvider(&stub_settings_provider_); | |
| 39 } | |
| 40 | |
| 41 void SettingsProviderTestBase::RestoreProvider() { | |
| 42 if (device_settings_provider_) { | |
|
bartfab (slow)
2015/03/31 14:12:41
Why is this conditional here? Do you expect Restor
| |
| 43 // Restore the real DeviceSettingsProvider. | |
| 44 CrosSettings* const cros_settings = CrosSettings::Get(); | |
| 45 EXPECT_TRUE( | |
| 46 cros_settings->RemoveSettingsProvider(&stub_settings_provider_)); | |
| 47 cros_settings->AddSettingsProvider(device_settings_provider_); | |
| 48 } | |
| 49 } | |
| 50 | |
| 51 void SettingsProviderTestBase::InitOwnerSettingsService(Profile* profile) { | |
| 52 owner_settings_service_.reset( | |
| 53 new chromeos::FakeOwnerSettingsService(profile)); | |
| 54 } | |
| 55 | |
| 56 } // namespace chromeos | |
| OLD | NEW |