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

Unified Diff: components/policy/core/common/forwarding_policy_provider_unittest.cc

Issue 337053005: Precache policy-for-extensions for device-local accounts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed ios tests Created 6 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 side-by-side diff with in-line comments
Download patch
Index: components/policy/core/common/forwarding_policy_provider_unittest.cc
diff --git a/components/policy/core/common/forwarding_policy_provider_unittest.cc b/components/policy/core/common/forwarding_policy_provider_unittest.cc
index bfce02be23cf0f1a089e236340c3fb65c4e05b11..430a0c8b2bc727c73663949b3ba56b039841c113 100644
--- a/components/policy/core/common/forwarding_policy_provider_unittest.cc
+++ b/components/policy/core/common/forwarding_policy_provider_unittest.cc
@@ -21,6 +21,18 @@ using testing::Return;
namespace policy {
+namespace {
+
+const char kTestSchema[] =
+ "{"
+ " \"type\": \"object\","
+ " \"properties\": {"
+ " \"foo\": { \"type\": \"string\" }"
+ " }"
+ "}";
+
+} // namespace
+
class ForwardingPolicyProviderTest : public testing::Test {
protected:
ForwardingPolicyProviderTest() : forwarding_provider_(&mock_provider_) {
@@ -35,6 +47,14 @@ class ForwardingPolicyProviderTest : public testing::Test {
mock_provider_.Shutdown();
}
+ Schema CreateTestSchema() {
+ std::string error;
bartfab (slow) 2014/06/23 09:53:37 Nit: #include <string>
Joao da Silva 2014/07/16 11:47:52 Done.
+ Schema schema = Schema::Parse(kTestSchema, &error);
+ if (!schema.valid())
+ ADD_FAILURE() << error;
+ return schema;
+ }
+
SchemaRegistry schema_registry_;
MockConfigurationPolicyObserver observer_;
MockConfigurationPolicyProvider mock_provider_;
@@ -66,7 +86,7 @@ TEST_F(ForwardingPolicyProviderTest, ForwardsChromePolicy) {
scoped_ptr<PolicyBundle> delegate_bundle(new PolicyBundle);
delegate_bundle->CopyFrom(bundle);
delegate_bundle->Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "xyz"))
- .Set("component policy", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ .Set("foo", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
base::Value::CreateStringValue("not forwarded"), NULL);
mock_provider_.UpdatePolicy(delegate_bundle.Pass());
Mock::VerifyAndClearExpectations(&observer_);
@@ -106,7 +126,7 @@ TEST_F(ForwardingPolicyProviderTest, SchemaReadyWithComponents) {
EXPECT_CALL(mock_provider_, RefreshPolicies()).Times(0);
schema_registry_.RegisterComponent(
- PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "xyz"), Schema());
+ PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "xyz"), CreateTestSchema());
schema_registry_.SetReady(POLICY_DOMAIN_EXTENSIONS);
Mock::VerifyAndClearExpectations(&mock_provider_);
@@ -134,7 +154,7 @@ TEST_F(ForwardingPolicyProviderTest, SchemaReadyWithComponents) {
TEST_F(ForwardingPolicyProviderTest, DelegateUpdates) {
schema_registry_.RegisterComponent(
- PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "xyz"), Schema());
+ PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "xyz"), CreateTestSchema());
EXPECT_FALSE(schema_registry_.IsReady());
EXPECT_FALSE(forwarding_provider_.IsInitializationComplete(
policy::POLICY_DOMAIN_EXTENSIONS));
@@ -174,7 +194,7 @@ 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_.RegisterComponent(ns, CreateTestSchema());
schema_registry_.SetReady(POLICY_DOMAIN_EXTENSIONS);
Mock::VerifyAndClearExpectations(&mock_provider_);
@@ -199,7 +219,7 @@ TEST_F(ForwardingPolicyProviderTest, RemoveAndAddComponent) {
// 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());
+ schema_registry_.RegisterComponent(ns, CreateTestSchema());
Mock::VerifyAndClearExpectations(&mock_provider_);
EXPECT_CALL(observer_, OnUpdatePolicy(_));

Powered by Google App Engine
This is Rietveld 408576698