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

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

Issue 851123003: Update {virtual,override,final} to follow C++11 style in chrome/browser/chromeos/settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_DEVICE_SETTINGS_TEST_HELPER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_ 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 22 matching lines...) Expand all
33 33
34 // A helper class for tests mocking out session_manager's device settings 34 // A helper class for tests mocking out session_manager's device settings
35 // interface. The pattern is to initialize DeviceSettingsService with the helper 35 // interface. The pattern is to initialize DeviceSettingsService with the helper
36 // for the SessionManagerClient pointer. The helper records calls made by 36 // for the SessionManagerClient pointer. The helper records calls made by
37 // DeviceSettingsService. The test can then verify state, after which it should 37 // DeviceSettingsService. The test can then verify state, after which it should
38 // call one of the Flush() variants that will resume processing. 38 // call one of the Flush() variants that will resume processing.
39 class DeviceSettingsTestHelper : public SessionManagerClient { 39 class DeviceSettingsTestHelper : public SessionManagerClient {
40 public: 40 public:
41 // Wraps a device settings service instance for testing. 41 // Wraps a device settings service instance for testing.
42 DeviceSettingsTestHelper(); 42 DeviceSettingsTestHelper();
43 virtual ~DeviceSettingsTestHelper(); 43 ~DeviceSettingsTestHelper() override;
44 44
45 // Runs all pending store callbacks. 45 // Runs all pending store callbacks.
46 void FlushStore(); 46 void FlushStore();
47 47
48 // Runs all pending retrieve callbacks. 48 // Runs all pending retrieve callbacks.
49 void FlushRetrieve(); 49 void FlushRetrieve();
50 50
51 // Flushes all pending operations. 51 // Flushes all pending operations.
52 void Flush(); 52 void Flush();
53 53
(...skipping 21 matching lines...) Expand all
75 return entry == device_local_account_policy_.end() ? 75 return entry == device_local_account_policy_.end() ?
76 base::EmptyString() : entry->second.policy_blob_; 76 base::EmptyString() : entry->second.policy_blob_;
77 } 77 }
78 78
79 void set_device_local_account_policy_blob(const std::string& id, 79 void set_device_local_account_policy_blob(const std::string& id,
80 const std::string& policy_blob) { 80 const std::string& policy_blob) {
81 device_local_account_policy_[id].policy_blob_ = policy_blob; 81 device_local_account_policy_[id].policy_blob_ = policy_blob;
82 } 82 }
83 83
84 // SessionManagerClient: 84 // SessionManagerClient:
85 virtual void Init(dbus::Bus* bus) override; 85 void Init(dbus::Bus* bus) override;
86 virtual void SetStubDelegate(SessionManagerClient::StubDelegate* delegate) 86 void SetStubDelegate(SessionManagerClient::StubDelegate* delegate) override;
87 override; 87 void AddObserver(Observer* observer) override;
88 virtual void AddObserver(Observer* observer) override; 88 void RemoveObserver(Observer* observer) override;
89 virtual void RemoveObserver(Observer* observer) override; 89 bool HasObserver(const Observer* observer) const override;
90 virtual bool HasObserver(const Observer* observer) const override; 90 bool IsScreenLocked() const override;
91 virtual bool IsScreenLocked() const override; 91 void EmitLoginPromptVisible() override;
92 virtual void EmitLoginPromptVisible() override; 92 void RestartJob(int pid, const std::string& command_line) override;
93 virtual void RestartJob(int pid, const std::string& command_line) override; 93 void StartSession(const std::string& user_email) override;
94 virtual void StartSession(const std::string& user_email) override; 94 void StopSession() override;
95 virtual void StopSession() override; 95 void NotifySupervisedUserCreationStarted() override;
96 virtual void NotifySupervisedUserCreationStarted() override; 96 void NotifySupervisedUserCreationFinished() override;
97 virtual void NotifySupervisedUserCreationFinished() override; 97 void StartDeviceWipe() override;
98 virtual void StartDeviceWipe() override; 98 void RequestLockScreen() override;
99 virtual void RequestLockScreen() override; 99 void NotifyLockScreenShown() override;
100 virtual void NotifyLockScreenShown() override; 100 void NotifyLockScreenDismissed() override;
101 virtual void NotifyLockScreenDismissed() override; 101 void RetrieveActiveSessions(const ActiveSessionsCallback& callback) override;
102 virtual void RetrieveActiveSessions( 102 void RetrieveDevicePolicy(const RetrievePolicyCallback& callback) override;
103 const ActiveSessionsCallback& callback) override; 103 void RetrievePolicyForUser(const std::string& username,
104 virtual void RetrieveDevicePolicy( 104 const RetrievePolicyCallback& callback) override;
105 const RetrievePolicyCallback& callback) override; 105 std::string BlockingRetrievePolicyForUser(
106 virtual void RetrievePolicyForUser(
107 const std::string& username,
108 const RetrievePolicyCallback& callback) override;
109 virtual std::string BlockingRetrievePolicyForUser(
110 const std::string& username) override; 106 const std::string& username) override;
111 virtual void RetrieveDeviceLocalAccountPolicy( 107 void RetrieveDeviceLocalAccountPolicy(
112 const std::string& account_id, 108 const std::string& account_id,
113 const RetrievePolicyCallback& callback) override; 109 const RetrievePolicyCallback& callback) override;
114 virtual void StoreDevicePolicy(const std::string& policy_blob, 110 void StoreDevicePolicy(const std::string& policy_blob,
115 const StorePolicyCallback& callback) override; 111 const StorePolicyCallback& callback) override;
116 virtual void StorePolicyForUser(const std::string& username, 112 void StorePolicyForUser(const std::string& username,
117 const std::string& policy_blob, 113 const std::string& policy_blob,
118 const StorePolicyCallback& callback) override; 114 const StorePolicyCallback& callback) override;
119 virtual void StoreDeviceLocalAccountPolicy( 115 void StoreDeviceLocalAccountPolicy(
120 const std::string& account_id, 116 const std::string& account_id,
121 const std::string& policy_blob, 117 const std::string& policy_blob,
122 const StorePolicyCallback& callback) override; 118 const StorePolicyCallback& callback) override;
123 virtual void SetFlagsForUser( 119 void SetFlagsForUser(const std::string& account_id,
124 const std::string& account_id, 120 const std::vector<std::string>& flags) override;
125 const std::vector<std::string>& flags) override; 121 void GetServerBackedStateKeys(const StateKeysCallback& callback) override;
126 virtual void GetServerBackedStateKeys(
127 const StateKeysCallback& callback) override;
128 122
129 private: 123 private:
130 struct PolicyState { 124 struct PolicyState {
131 bool store_result_; 125 bool store_result_;
132 std::string policy_blob_; 126 std::string policy_blob_;
133 std::vector<StorePolicyCallback> store_callbacks_; 127 std::vector<StorePolicyCallback> store_callbacks_;
134 std::vector<RetrievePolicyCallback> retrieve_callbacks_; 128 std::vector<RetrievePolicyCallback> retrieve_callbacks_;
135 129
136 PolicyState(); 130 PolicyState();
137 ~PolicyState(); 131 ~PolicyState();
138 132
139 bool HasPendingOperations() const { 133 bool HasPendingOperations() const {
140 return !store_callbacks_.empty() || !retrieve_callbacks_.empty(); 134 return !store_callbacks_.empty() || !retrieve_callbacks_.empty();
141 } 135 }
142 }; 136 };
143 137
144 PolicyState device_policy_; 138 PolicyState device_policy_;
145 std::map<std::string, PolicyState> device_local_account_policy_; 139 std::map<std::string, PolicyState> device_local_account_policy_;
146 140
147 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsTestHelper); 141 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsTestHelper);
148 }; 142 };
149 143
150 // Wraps the singleton device settings and initializes it to the point where it 144 // Wraps the singleton device settings and initializes it to the point where it
151 // reports OWNERSHIP_NONE for the ownership status. 145 // reports OWNERSHIP_NONE for the ownership status.
152 class ScopedDeviceSettingsTestHelper : public DeviceSettingsTestHelper { 146 class ScopedDeviceSettingsTestHelper : public DeviceSettingsTestHelper {
153 public: 147 public:
154 ScopedDeviceSettingsTestHelper(); 148 ScopedDeviceSettingsTestHelper();
155 virtual ~ScopedDeviceSettingsTestHelper(); 149 ~ScopedDeviceSettingsTestHelper() override;
156 150
157 private: 151 private:
158 DISALLOW_COPY_AND_ASSIGN(ScopedDeviceSettingsTestHelper); 152 DISALLOW_COPY_AND_ASSIGN(ScopedDeviceSettingsTestHelper);
159 }; 153 };
160 154
161 // A convenience test base class that initializes a DeviceSettingsService 155 // A convenience test base class that initializes a DeviceSettingsService
162 // instance for testing and allows for straightforward updating of device 156 // instance for testing and allows for straightforward updating of device
163 // settings. |device_settings_service_| starts out in uninitialized state, so 157 // settings. |device_settings_service_| starts out in uninitialized state, so
164 // startup code gets tested as well. 158 // startup code gets tested as well.
165 class DeviceSettingsTestBase : public testing::Test { 159 class DeviceSettingsTestBase : public testing::Test {
166 protected: 160 protected:
167 DeviceSettingsTestBase(); 161 DeviceSettingsTestBase();
168 virtual ~DeviceSettingsTestBase(); 162 ~DeviceSettingsTestBase() override;
169 163
170 virtual void SetUp() override; 164 void SetUp() override;
171 virtual void TearDown() override; 165 void TearDown() override;
172 166
173 // Flushes any pending device settings operations. 167 // Flushes any pending device settings operations.
174 void FlushDeviceSettings(); 168 void FlushDeviceSettings();
175 169
176 // Triggers an owner key and device settings reload on 170 // Triggers an owner key and device settings reload on
177 // |device_settings_service_| and flushes the resulting load operation. 171 // |device_settings_service_| and flushes the resulting load operation.
178 void ReloadDeviceSettings(); 172 void ReloadDeviceSettings();
179 173
180 void InitOwner(const std::string& user_id, bool tpm_is_ready); 174 void InitOwner(const std::string& user_id, bool tpm_is_ready);
181 175
(...skipping 14 matching lines...) Expand all
196 190
197 scoped_ptr<DBusThreadManagerSetter> dbus_setter_; 191 scoped_ptr<DBusThreadManagerSetter> dbus_setter_;
198 192
199 private: 193 private:
200 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsTestBase); 194 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsTestBase);
201 }; 195 };
202 196
203 } // namespace chromeos 197 } // namespace chromeos
204 198
205 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_ 199 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698