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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/forwarding_policy_provider_unittest.cc
diff --git a/chrome/browser/policy/forwarding_policy_provider_unittest.cc b/chrome/browser/policy/forwarding_policy_provider_unittest.cc
index 77c55089040e494cf5dc3e9d153b76f95d234eac..b14d719fc9ec5bb322d815e4e98bd42b5a763caa 100644
--- a/chrome/browser/policy/forwarding_policy_provider_unittest.cc
+++ b/chrome/browser/policy/forwarding_policy_provider_unittest.cc
@@ -170,4 +170,44 @@ TEST_F(ForwardingPolicyProviderTest, DelegateUpdates) {
Mock::VerifyAndClearExpectations(&observer_);
}
+TEST_F(ForwardingPolicyProviderTest, RemoveAndAddComponent) {
+ EXPECT_CALL(mock_provider_, RefreshPolicies());
+ const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, "xyz");
+ schema_registry_.SetReady(POLICY_DOMAIN_CHROME);
+ schema_registry_.RegisterComponent(ns, Schema());
+ schema_registry_.SetReady(POLICY_DOMAIN_EXTENSIONS);
+ Mock::VerifyAndClearExpectations(&mock_provider_);
+
+ // Serve policy for |ns|.
+ PolicyBundle platform_policy;
+ platform_policy.Get(ns).Set("foo", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ base::Value::CreateStringValue("omg"), NULL);
+ scoped_ptr<PolicyBundle> copy(new PolicyBundle);
+ copy->CopyFrom(platform_policy);
+ EXPECT_CALL(observer_, OnUpdatePolicy(_));
+ mock_provider_.UpdatePolicy(copy.Pass());
+ Mock::VerifyAndClearExpectations(&observer_);
+ EXPECT_TRUE(forwarding_provider_.policies().Equals(platform_policy));
+
+ // Now remove that component.
+ EXPECT_CALL(observer_, OnUpdatePolicy(_));
+ schema_registry_.UnregisterComponent(ns);
+ Mock::VerifyAndClearExpectations(&observer_);
+ const PolicyBundle empty;
+ EXPECT_TRUE(forwarding_provider_.policies().Equals(empty));
+
+ // Adding it back should serve the current policies again, even though they
+ // haven't changed on the platform provider.
+ EXPECT_CALL(mock_provider_, RefreshPolicies());
+ schema_registry_.RegisterComponent(ns, Schema());
+ Mock::VerifyAndClearExpectations(&mock_provider_);
+
+ EXPECT_CALL(observer_, OnUpdatePolicy(_));
+ copy.reset(new PolicyBundle);
+ copy->CopyFrom(platform_policy);
+ mock_provider_.UpdatePolicy(copy.Pass());
+ Mock::VerifyAndClearExpectations(&observer_);
+ EXPECT_TRUE(forwarding_provider_.policies().Equals(platform_policy));
+}
+
} // namespace policy
« 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