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

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: Nits. 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.
bartfab (slow) 2015/04/10 08:38:13 Nit: s/(c) //
Ivan Podogov 2015/04/10 09:50:53 Done.
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 "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.
13 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
14
15 class Profile;
16
17 namespace chromeos {
18
19 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.
20 class FakeOwnerSettingsService;
21 class ScopedTestCrosSettings;
22 class ScopedTestDeviceSettingsService;
23
24 class ScopedCrosSettingsTestHelper {
25 public:
26 ScopedCrosSettingsTestHelper();
27
28 // In some cases it is required to pass |create_settings_service| as false:
29 // 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.
30 // 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.
31 explicit ScopedCrosSettingsTestHelper(bool create_settings_service);
32 virtual ~ScopedCrosSettingsTestHelper();
bartfab (slow) 2015/04/10 08:38:13 Nit: s/virtual //
Ivan Podogov 2015/04/10 09:50:53 Done.
33
34 // Methods to replace and restore CrosSettingsProvider for the specified
35 // |path|.
36 void ReplaceProvider(const std::string& path);
37 void RestoreProvider();
38
39 // Method to create an owner settings service that uses
40 // |stub_settings_provider_| as settings write path.
41 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.
42
43 // These methods simply call the according |stub_settings_provider_| method.
44 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.
45 void SetCurrentUserIsOwner(bool owner);
46 void Set(const std::string& path, const base::Value& in_value);
47
48 // Convenience forms of Set() from CrosSettingsProvider. These methods will
49 // replace any existing value at that |path|, even if it has a different type.
50 void SetBoolean(const std::string& path, bool in_value);
51 void SetInteger(const std::string& path, int in_value);
52 void SetDouble(const std::string& path, double in_value);
53 void SetString(const std::string& path, const std::string& in_value);
54
55 // This may be called before |ReplaceProvider| to copy values currently stored
56 // in the old provider. If the method is called after |ReplaceProvider|, then
57 // the value is retreived from |real_settings_provider_| for any |path|.
58 void CopyStoredValue(const std::string& path);
59
60 // Write the setting from |path| to local state so that it can be retreived
61 // later on browser test startup by the device settings service.
62 void StoreCachedDeviceSetting(const std::string& path);
63
64 private:
65 // Helpers used to mock out cros settings.
66 scoped_ptr<ScopedTestDeviceSettingsService> test_device_settings_service_;
67 scoped_ptr<ScopedTestCrosSettings> test_cros_settings_;
68 CrosSettingsProvider* real_settings_provider_ = nullptr;
69 StubCrosSettingsProvider stub_settings_provider_;
70
71 void Initialize(bool create_settings_service);
72
73 DISALLOW_COPY_AND_ASSIGN(ScopedCrosSettingsTestHelper);
74 };
75
76 } // namespace chromeos
77
78 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SCOPED_CROS_SETTINGS_TEST_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698