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 "testing/gtest/include/gtest/gtest.h" | |
9 | |
10 namespace chromeos { | |
11 | |
12 SettingsProviderTestBase::SettingsProviderTestBase() { | |
13 if (!DeviceSettingsService::IsInitialized()) { | |
14 test_device_settings_service_.reset(new ScopedTestDeviceSettingsService()); | |
15 test_cros_settings_.reset(new ScopedTestCrosSettings()); | |
16 } | |
17 } | |
18 | |
19 SettingsProviderTestBase::SettingsProviderTestBase( | |
20 bool create_settings_service) { | |
21 if (create_settings_service && !DeviceSettingsService::IsInitialized()) { | |
22 test_device_settings_service_.reset(new ScopedTestDeviceSettingsService()); | |
23 test_cros_settings_.reset(new ScopedTestCrosSettings()); | |
24 } | |
25 } | |
26 | |
27 SettingsProviderTestBase::~SettingsProviderTestBase() { | |
28 } | |
29 | |
30 void SettingsProviderTestBase::ReplaceProvider(const std::string& path) { | |
31 // Swap out the DeviceSettingsProvider with our settings provider so we can | |
32 // set values for the specified path. | |
33 CrosSettings* const cros_settings = CrosSettings::Get(); | |
34 device_settings_provider_ = cros_settings->GetProvider(path); | |
35 EXPECT_TRUE(device_settings_provider_); | |
36 EXPECT_TRUE(cros_settings->RemoveSettingsProvider(device_settings_provider_)); | |
37 cros_settings->AddSettingsProvider(&stub_settings_provider_); | |
38 } | |
39 | |
40 void SettingsProviderTestBase::RestoreProvider() { | |
41 if (device_settings_provider_) { | |
42 // Restore the real DeviceSettingsProvider. | |
43 CrosSettings* const cros_settings = CrosSettings::Get(); | |
44 EXPECT_TRUE( | |
45 cros_settings->RemoveSettingsProvider(&stub_settings_provider_)); | |
46 cros_settings->AddSettingsProvider(device_settings_provider_); | |
47 } | |
48 } | |
49 | |
50 void SettingsProviderTestBase::InitOwnerSettingsService(Profile* profile) { | |
51 owner_settings_service_.reset( | |
52 new chromeos::FakeOwnerSettingsService(profile)); | |
Mattias Nissler (ping if slow)
2015/03/30 14:45:46
Does this also correctly associate the created ser
Ivan Podogov
2015/03/31 08:40:00
It doesn't. I'll add the builder where necessary.
| |
53 } | |
54 | |
55 } // namespace chromeos | |
OLD | NEW |