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

Side by Side Diff: chrome/browser/policy/forwarding_policy_provider_unittest.cc

Issue 78953002: Fixes and improvements to cloud policy for extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/policy/forwarding_policy_provider.h" 5 #include "chrome/browser/policy/forwarding_policy_provider.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/policy/mock_configuration_policy_provider.h" 9 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
10 #include "components/policy/core/common/policy_bundle.h" 10 #include "components/policy/core/common/policy_bundle.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 EXPECT_TRUE(forwarding_provider_.IsInitializationComplete( 164 EXPECT_TRUE(forwarding_provider_.IsInitializationComplete(
165 policy::POLICY_DOMAIN_EXTENSIONS)); 165 policy::POLICY_DOMAIN_EXTENSIONS));
166 166
167 // Keeps forwarding. 167 // Keeps forwarding.
168 EXPECT_CALL(observer_, OnUpdatePolicy(_)); 168 EXPECT_CALL(observer_, OnUpdatePolicy(_));
169 mock_provider_.UpdateChromePolicy(policy_map); 169 mock_provider_.UpdateChromePolicy(policy_map);
170 Mock::VerifyAndClearExpectations(&observer_); 170 Mock::VerifyAndClearExpectations(&observer_);
171 } 171 }
172 172
173 TEST_F(ForwardingPolicyProviderTest, RemoveAndAddComponent) {
174 EXPECT_CALL(mock_provider_, RefreshPolicies());
175 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, "xyz");
176 schema_registry_.SetReady(POLICY_DOMAIN_CHROME);
177 schema_registry_.RegisterComponent(ns, Schema());
178 schema_registry_.SetReady(POLICY_DOMAIN_EXTENSIONS);
179 Mock::VerifyAndClearExpectations(&mock_provider_);
180
181 // Serve policy for |ns|.
182 PolicyBundle platform_policy;
183 platform_policy.Get(ns).Set("foo", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
184 base::Value::CreateStringValue("omg"), NULL);
185 scoped_ptr<PolicyBundle> copy(new PolicyBundle);
186 copy->CopyFrom(platform_policy);
187 EXPECT_CALL(observer_, OnUpdatePolicy(_));
188 mock_provider_.UpdatePolicy(copy.Pass());
189 Mock::VerifyAndClearExpectations(&observer_);
190 EXPECT_TRUE(forwarding_provider_.policies().Equals(platform_policy));
191
192 // Now remove that component.
193 EXPECT_CALL(observer_, OnUpdatePolicy(_));
194 schema_registry_.UnregisterComponent(ns);
195 Mock::VerifyAndClearExpectations(&observer_);
196 const PolicyBundle empty;
197 EXPECT_TRUE(forwarding_provider_.policies().Equals(empty));
198
199 // Adding it back should serve the current policies again, even though they
200 // haven't changed on the platform provider.
201 EXPECT_CALL(mock_provider_, RefreshPolicies());
202 schema_registry_.RegisterComponent(ns, Schema());
203 Mock::VerifyAndClearExpectations(&mock_provider_);
204
205 EXPECT_CALL(observer_, OnUpdatePolicy(_));
206 copy.reset(new PolicyBundle);
207 copy->CopyFrom(platform_policy);
208 mock_provider_.UpdatePolicy(copy.Pass());
209 Mock::VerifyAndClearExpectations(&observer_);
210 EXPECT_TRUE(forwarding_provider_.policies().Equals(platform_policy));
211 }
212
173 } // namespace policy 213 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/forwarding_policy_provider.cc ('k') | chrome/browser/ui/webui/policy_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698