Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h

Issue 1019283004: Switch to direct use of OwnerSettingsServiceChromeOS::Set() in tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace inheritance with composition. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_SCOPED_CROS_SETTINGS_TEST_HELPER_H_
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_SCOPED_CROS_SETTINGS_TEST_HELPER_H_
7
8 #include <string>
9
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/chromeos/settings/device_settings_provider.h"
13 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
14
15 class KeyedService;
16 class Profile;
17
18 namespace content {
19 class BrowserContext;
20 }
21
22 namespace chromeos {
23
24 class FakeOwnerSettingsService;
25 class ScopedTestCrosSettings;
26 class ScopedTestDeviceSettingsService;
27
28 class ScopedCrosSettingsTestHelper {
29 public:
30 ScopedCrosSettingsTestHelper();
31
32 // In some cases it is required to pass |create_settings_service| as false:
33 // if the test already has a device settings service and/or CrosSettings set
34 // up by another bundle, creating another one causes crash.
35 explicit ScopedCrosSettingsTestHelper(bool create_settings_service);
36 virtual ~ScopedCrosSettingsTestHelper();
37
38 // Methods to replace and restore CrosSettingsProvider for the specified path.
39 void ReplaceProvider(const std::string& path);
40 void RestoreProvider();
41
42 // Method to create an owner settings service that uses
43 // stub_settings_provider_ as settings write path.
44 FakeOwnerSettingsService* CreateOwnerSettingsService(Profile* profile);
45
46 // Convenience forms of Set() from CrosSettingsProvider. These methods will
47 // replace any existing value at that |path|, even if it has a different type.
48 void SetBoolean(const std::string& path, bool in_value);
49 void SetInteger(const std::string& path, int in_value);
50 void SetDouble(const std::string& path, double in_value);
51 void SetString(const std::string& path, const std::string& in_value);
52
53 private:
54 // Helpers used to mock out cros settings.
55 scoped_ptr<ScopedTestDeviceSettingsService> test_device_settings_service_;
56 scoped_ptr<ScopedTestCrosSettings> test_cros_settings_;
57 CrosSettingsProvider* device_settings_provider_ = nullptr;
58 StubCrosSettingsProvider stub_settings_provider_;
59
60 void Initialize(bool create_settings_service);
61
62 DISALLOW_COPY_AND_ASSIGN(ScopedCrosSettingsTestHelper);
63 };
64
65 } // namespace chromeos
66
67 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SCOPED_CROS_SETTINGS_TEST_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698