Index: chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h |
diff --git a/chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h b/chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6abc0481a5ef6472b3820d4c8b386ae68e88fee0 |
--- /dev/null |
+++ b/chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h |
@@ -0,0 +1,78 @@ |
+// Copyright (c) 2015 The Chromium Authors. All rights reserved. |
bartfab (slow)
2015/04/10 08:38:13
Nit: s/(c) //
Ivan Podogov
2015/04/10 09:50:53
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_SCOPED_CROS_SETTINGS_TEST_HELPER_H_ |
+#define CHROME_BROWSER_CHROMEOS_SETTINGS_SCOPED_CROS_SETTINGS_TEST_HELPER_H_ |
+ |
+#include <string> |
+ |
+#include "base/macros.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/values.h" |
bartfab (slow)
2015/04/10 08:38:13
Nit: Forward-declare |base::Value| instead.
Ivan Podogov
2015/04/10 09:50:53
Done.
|
+#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
+ |
+class Profile; |
+ |
+namespace chromeos { |
+ |
+class CrosSettingsProvider; |
bartfab (slow)
2015/04/10 08:38:13
Nit: Not needed once you include "chromeos/setting
Ivan Podogov
2015/04/10 09:50:53
Done.
|
+class FakeOwnerSettingsService; |
+class ScopedTestCrosSettings; |
+class ScopedTestDeviceSettingsService; |
+ |
+class ScopedCrosSettingsTestHelper { |
+ public: |
+ ScopedCrosSettingsTestHelper(); |
+ |
+ // In some cases it is required to pass |create_settings_service| as false: |
+ // if the test already has a device settings service and/or CrosSettings set |
bartfab (slow)
2015/04/10 08:38:13
Nit: s/if/If/
Ivan Podogov
2015/04/10 09:50:53
Done.
|
+ // up by another bundle, creating another one causes crash. |
bartfab (slow)
2015/04/10 08:38:13
Nit: What is a "bundle"?
Ivan Podogov
2015/04/10 09:50:53
Done.
|
+ explicit ScopedCrosSettingsTestHelper(bool create_settings_service); |
+ virtual ~ScopedCrosSettingsTestHelper(); |
bartfab (slow)
2015/04/10 08:38:13
Nit: s/virtual //
Ivan Podogov
2015/04/10 09:50:53
Done.
|
+ |
+ // Methods to replace and restore CrosSettingsProvider for the specified |
+ // |path|. |
+ void ReplaceProvider(const std::string& path); |
+ void RestoreProvider(); |
+ |
+ // Method to create an owner settings service that uses |
+ // |stub_settings_provider_| as settings write path. |
+ FakeOwnerSettingsService* CreateOwnerSettingsService(Profile* profile); |
bartfab (slow)
2015/04/10 08:38:13
Nit: This appears to pass ownership. Please use sc
Ivan Podogov
2015/04/10 09:50:53
Done.
|
+ |
+ // These methods simply call the according |stub_settings_provider_| method. |
+ void SetTrustedStatus(CrosSettingsProvider::TrustedStatus status); |
bartfab (slow)
2015/04/10 08:38:13
Nit: #include "chromeos/settings/cros_settings_pro
Ivan Podogov
2015/04/10 09:50:53
Done.
|
+ void SetCurrentUserIsOwner(bool owner); |
+ void Set(const std::string& path, const base::Value& in_value); |
+ |
+ // Convenience forms of Set() from CrosSettingsProvider. These methods will |
+ // replace any existing value at that |path|, even if it has a different type. |
+ void SetBoolean(const std::string& path, bool in_value); |
+ void SetInteger(const std::string& path, int in_value); |
+ void SetDouble(const std::string& path, double in_value); |
+ void SetString(const std::string& path, const std::string& in_value); |
+ |
+ // This may be called before |ReplaceProvider| to copy values currently stored |
+ // in the old provider. If the method is called after |ReplaceProvider|, then |
+ // the value is retreived from |real_settings_provider_| for any |path|. |
+ void CopyStoredValue(const std::string& path); |
+ |
+ // Write the setting from |path| to local state so that it can be retreived |
+ // later on browser test startup by the device settings service. |
+ void StoreCachedDeviceSetting(const std::string& path); |
+ |
+ private: |
+ // Helpers used to mock out cros settings. |
+ scoped_ptr<ScopedTestDeviceSettingsService> test_device_settings_service_; |
+ scoped_ptr<ScopedTestCrosSettings> test_cros_settings_; |
+ CrosSettingsProvider* real_settings_provider_ = nullptr; |
+ StubCrosSettingsProvider stub_settings_provider_; |
+ |
+ void Initialize(bool create_settings_service); |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ScopedCrosSettingsTestHelper); |
+}; |
+ |
+} // namespace chromeos |
+ |
+#endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SCOPED_CROS_SETTINGS_TEST_HELPER_H_ |