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

Side by Side Diff: chrome/browser/extensions/api/storage/policy_value_store_unittest.cc

Issue 2083363002: Remove calls to deprecated MessageLoop methods in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 #include "chrome/browser/extensions/api/storage/policy_value_store.h" 5 #include "chrome/browser/extensions/api/storage/policy_value_store.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/run_loop.h"
16 #include "components/policy/core/common/external_data_fetcher.h" 17 #include "components/policy/core/common/external_data_fetcher.h"
17 #include "components/policy/core/common/policy_map.h" 18 #include "components/policy/core/common/policy_map.h"
18 #include "components/policy/core/common/policy_types.h" 19 #include "components/policy/core/common/policy_types.h"
19 #include "content/public/test/test_browser_thread.h" 20 #include "content/public/test/test_browser_thread.h"
20 #include "extensions/browser/api/storage/settings_observer.h" 21 #include "extensions/browser/api/storage/settings_observer.h"
21 #include "extensions/browser/value_store/leveldb_value_store.h" 22 #include "extensions/browser/value_store/leveldb_value_store.h"
22 #include "extensions/browser/value_store/value_store_unittest.h" 23 #include "extensions/browser/value_store/value_store_unittest.h"
23 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 26
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 EXPECT_CALL(observer_, 166 EXPECT_CALL(observer_,
166 OnSettingsChanged(kTestExtensionId, 167 OnSettingsChanged(kTestExtensionId,
167 settings_namespace::MANAGED, 168 settings_namespace::MANAGED,
168 ValueStoreChange::ToJson(changes))); 169 ValueStoreChange::ToJson(changes)));
169 } 170 }
170 171
171 policy::PolicyMap policies; 172 policy::PolicyMap policies;
172 policies.Set("aaa", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, 173 policies.Set("aaa", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
173 policy::POLICY_SOURCE_CLOUD, value.CreateDeepCopy(), nullptr); 174 policy::POLICY_SOURCE_CLOUD, value.CreateDeepCopy(), nullptr);
174 store_->SetCurrentPolicy(policies); 175 store_->SetCurrentPolicy(policies);
175 loop_.RunUntilIdle(); 176 base::RunLoop().RunUntilIdle();
176 Mock::VerifyAndClearExpectations(&observer_); 177 Mock::VerifyAndClearExpectations(&observer_);
177 178
178 // Notify when new policies are added. 179 // Notify when new policies are added.
179 { 180 {
180 ValueStoreChangeList changes; 181 ValueStoreChangeList changes;
181 changes.push_back(ValueStoreChange("bbb", nullptr, value.CreateDeepCopy())); 182 changes.push_back(ValueStoreChange("bbb", nullptr, value.CreateDeepCopy()));
182 EXPECT_CALL(observer_, 183 EXPECT_CALL(observer_,
183 OnSettingsChanged(kTestExtensionId, 184 OnSettingsChanged(kTestExtensionId,
184 settings_namespace::MANAGED, 185 settings_namespace::MANAGED,
185 ValueStoreChange::ToJson(changes))); 186 ValueStoreChange::ToJson(changes)));
186 } 187 }
187 188
188 policies.Set("bbb", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, 189 policies.Set("bbb", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
189 policy::POLICY_SOURCE_CLOUD, value.CreateDeepCopy(), nullptr); 190 policy::POLICY_SOURCE_CLOUD, value.CreateDeepCopy(), nullptr);
190 store_->SetCurrentPolicy(policies); 191 store_->SetCurrentPolicy(policies);
191 loop_.RunUntilIdle(); 192 base::RunLoop().RunUntilIdle();
192 Mock::VerifyAndClearExpectations(&observer_); 193 Mock::VerifyAndClearExpectations(&observer_);
193 194
194 // Notify when policies change. 195 // Notify when policies change.
195 const base::StringValue new_value("222"); 196 const base::StringValue new_value("222");
196 { 197 {
197 ValueStoreChangeList changes; 198 ValueStoreChangeList changes;
198 changes.push_back(ValueStoreChange("bbb", value.CreateDeepCopy(), 199 changes.push_back(ValueStoreChange("bbb", value.CreateDeepCopy(),
199 new_value.CreateDeepCopy())); 200 new_value.CreateDeepCopy()));
200 EXPECT_CALL(observer_, 201 EXPECT_CALL(observer_,
201 OnSettingsChanged(kTestExtensionId, 202 OnSettingsChanged(kTestExtensionId,
202 settings_namespace::MANAGED, 203 settings_namespace::MANAGED,
203 ValueStoreChange::ToJson(changes))); 204 ValueStoreChange::ToJson(changes)));
204 } 205 }
205 206
206 policies.Set("bbb", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, 207 policies.Set("bbb", policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
207 policy::POLICY_SOURCE_CLOUD, new_value.CreateDeepCopy(), 208 policy::POLICY_SOURCE_CLOUD, new_value.CreateDeepCopy(),
208 nullptr); 209 nullptr);
209 store_->SetCurrentPolicy(policies); 210 store_->SetCurrentPolicy(policies);
210 loop_.RunUntilIdle(); 211 base::RunLoop().RunUntilIdle();
211 Mock::VerifyAndClearExpectations(&observer_); 212 Mock::VerifyAndClearExpectations(&observer_);
212 213
213 // Notify when policies are removed. 214 // Notify when policies are removed.
214 { 215 {
215 ValueStoreChangeList changes; 216 ValueStoreChangeList changes;
216 changes.push_back( 217 changes.push_back(
217 ValueStoreChange("bbb", new_value.CreateDeepCopy(), nullptr)); 218 ValueStoreChange("bbb", new_value.CreateDeepCopy(), nullptr));
218 EXPECT_CALL(observer_, 219 EXPECT_CALL(observer_,
219 OnSettingsChanged(kTestExtensionId, 220 OnSettingsChanged(kTestExtensionId,
220 settings_namespace::MANAGED, 221 settings_namespace::MANAGED,
221 ValueStoreChange::ToJson(changes))); 222 ValueStoreChange::ToJson(changes)));
222 } 223 }
223 224
224 policies.Erase("bbb"); 225 policies.Erase("bbb");
225 store_->SetCurrentPolicy(policies); 226 store_->SetCurrentPolicy(policies);
226 loop_.RunUntilIdle(); 227 base::RunLoop().RunUntilIdle();
227 Mock::VerifyAndClearExpectations(&observer_); 228 Mock::VerifyAndClearExpectations(&observer_);
228 229
229 // Don't notify when there aren't any changes. 230 // Don't notify when there aren't any changes.
230 EXPECT_CALL(observer_, OnSettingsChanged(_, _, _)).Times(0); 231 EXPECT_CALL(observer_, OnSettingsChanged(_, _, _)).Times(0);
231 store_->SetCurrentPolicy(policies); 232 store_->SetCurrentPolicy(policies);
232 loop_.RunUntilIdle(); 233 base::RunLoop().RunUntilIdle();
233 Mock::VerifyAndClearExpectations(&observer_); 234 Mock::VerifyAndClearExpectations(&observer_);
234 } 235 }
235 236
236 } // namespace extensions 237 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698