| 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..40999601c6035caf8f2ceeb60394f54c7e11fa00
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h
|
| @@ -0,0 +1,67 @@
|
| +// Copyright (c) 2015 The Chromium Authors. All rights reserved.
|
| +// 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 "chrome/browser/chromeos/settings/device_settings_provider.h"
|
| +#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
|
| +
|
| +class KeyedService;
|
| +class Profile;
|
| +
|
| +namespace content {
|
| +class BrowserContext;
|
| +}
|
| +
|
| +namespace chromeos {
|
| +
|
| +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
|
| + // up by another bundle, creating another one causes crash.
|
| + explicit ScopedCrosSettingsTestHelper(bool create_settings_service);
|
| + virtual ~ScopedCrosSettingsTestHelper();
|
| +
|
| + // 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);
|
| +
|
| + // 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);
|
| +
|
| + private:
|
| + // Helpers used to mock out cros settings.
|
| + scoped_ptr<ScopedTestDeviceSettingsService> test_device_settings_service_;
|
| + scoped_ptr<ScopedTestCrosSettings> test_cros_settings_;
|
| + CrosSettingsProvider* device_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_
|
|
|