| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_SCOPED_CROS_SETTINGS_TEST_HELPER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_SCOPED_CROS_SETTINGS_TEST_HELPER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_SCOPED_CROS_SETTINGS_TEST_HELPER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_SCOPED_CROS_SETTINGS_TEST_HELPER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" | 12 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
| 13 #include "chromeos/settings/cros_settings_provider.h" | 13 #include "chromeos/settings/cros_settings_provider.h" |
| 14 | 14 |
| 15 class Profile; | 15 class Profile; |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class Value; | 18 class Value; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace chromeos { | 21 namespace chromeos { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 35 explicit ScopedCrosSettingsTestHelper(bool create_settings_service); | 35 explicit ScopedCrosSettingsTestHelper(bool create_settings_service); |
| 36 ~ScopedCrosSettingsTestHelper(); | 36 ~ScopedCrosSettingsTestHelper(); |
| 37 | 37 |
| 38 // Methods to replace and restore CrosSettingsProvider for the specified | 38 // Methods to replace and restore CrosSettingsProvider for the specified |
| 39 // |path|. | 39 // |path|. |
| 40 void ReplaceProvider(const std::string& path); | 40 void ReplaceProvider(const std::string& path); |
| 41 void RestoreProvider(); | 41 void RestoreProvider(); |
| 42 | 42 |
| 43 // Method to create an owner settings service that uses | 43 // Method to create an owner settings service that uses |
| 44 // |stub_settings_provider_| as settings write path. | 44 // |stub_settings_provider_| as settings write path. |
| 45 scoped_ptr<FakeOwnerSettingsService> CreateOwnerSettingsService( | 45 std::unique_ptr<FakeOwnerSettingsService> CreateOwnerSettingsService( |
| 46 Profile* profile); | 46 Profile* profile); |
| 47 | 47 |
| 48 // These methods simply call the according |stub_settings_provider_| method. | 48 // These methods simply call the according |stub_settings_provider_| method. |
| 49 void SetTrustedStatus(CrosSettingsProvider::TrustedStatus status); | 49 void SetTrustedStatus(CrosSettingsProvider::TrustedStatus status); |
| 50 void SetCurrentUserIsOwner(bool owner); | 50 void SetCurrentUserIsOwner(bool owner); |
| 51 void Set(const std::string& path, const base::Value& in_value); | 51 void Set(const std::string& path, const base::Value& in_value); |
| 52 | 52 |
| 53 // Convenience forms of Set() from CrosSettingsProvider. These methods will | 53 // Convenience forms of Set() from CrosSettingsProvider. These methods will |
| 54 // replace any existing value at that |path|, even if it has a different type. | 54 // replace any existing value at that |path|, even if it has a different type. |
| 55 void SetBoolean(const std::string& path, bool in_value); | 55 void SetBoolean(const std::string& path, bool in_value); |
| 56 void SetInteger(const std::string& path, int in_value); | 56 void SetInteger(const std::string& path, int in_value); |
| 57 void SetDouble(const std::string& path, double in_value); | 57 void SetDouble(const std::string& path, double in_value); |
| 58 void SetString(const std::string& path, const std::string& in_value); | 58 void SetString(const std::string& path, const std::string& in_value); |
| 59 | 59 |
| 60 // This may be called before |ReplaceProvider| to copy values currently stored | 60 // This may be called before |ReplaceProvider| to copy values currently stored |
| 61 // in the old provider. If the method is called after |ReplaceProvider|, then | 61 // in the old provider. If the method is called after |ReplaceProvider|, then |
| 62 // the value is retreived from |real_settings_provider_| for any |path|. | 62 // the value is retreived from |real_settings_provider_| for any |path|. |
| 63 void CopyStoredValue(const std::string& path); | 63 void CopyStoredValue(const std::string& path); |
| 64 | 64 |
| 65 // Write the setting from |path| to local state so that it can be retreived | 65 // Write the setting from |path| to local state so that it can be retreived |
| 66 // later on browser test startup by the device settings service. | 66 // later on browser test startup by the device settings service. |
| 67 void StoreCachedDeviceSetting(const std::string& path); | 67 void StoreCachedDeviceSetting(const std::string& path); |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 // Helpers used to mock out cros settings. | 70 // Helpers used to mock out cros settings. |
| 71 scoped_ptr<ScopedTestDeviceSettingsService> test_device_settings_service_; | 71 std::unique_ptr<ScopedTestDeviceSettingsService> |
| 72 scoped_ptr<ScopedTestCrosSettings> test_cros_settings_; | 72 test_device_settings_service_; |
| 73 std::unique_ptr<ScopedTestCrosSettings> test_cros_settings_; |
| 73 CrosSettingsProvider* real_settings_provider_ = nullptr; | 74 CrosSettingsProvider* real_settings_provider_ = nullptr; |
| 74 StubCrosSettingsProvider stub_settings_provider_; | 75 StubCrosSettingsProvider stub_settings_provider_; |
| 75 | 76 |
| 76 void Initialize(bool create_settings_service); | 77 void Initialize(bool create_settings_service); |
| 77 | 78 |
| 78 DISALLOW_COPY_AND_ASSIGN(ScopedCrosSettingsTestHelper); | 79 DISALLOW_COPY_AND_ASSIGN(ScopedCrosSettingsTestHelper); |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 } // namespace chromeos | 82 } // namespace chromeos |
| 82 | 83 |
| 83 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SCOPED_CROS_SETTINGS_TEST_HELPER_H_ | 84 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SCOPED_CROS_SETTINGS_TEST_HELPER_H_ |
| OLD | NEW |