OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "components/policy/core/common/external_data_fetcher.h" | 7 #include "components/policy/core/common/external_data_fetcher.h" |
8 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 8 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
9 #include "components/policy/core/common/proxy_policy_provider.h" | 9 #include "components/policy/core/common/proxy_policy_provider.h" |
10 #include "components/policy/core/common/schema_registry.h" | 10 #include "components/policy/core/common/schema_registry.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 EXPECT_TRUE(proxy_provider_.IsInitializationComplete(POLICY_DOMAIN_CHROME)); | 47 EXPECT_TRUE(proxy_provider_.IsInitializationComplete(POLICY_DOMAIN_CHROME)); |
48 EXPECT_TRUE(PolicyBundle().Equals(proxy_provider_.policies())); | 48 EXPECT_TRUE(PolicyBundle().Equals(proxy_provider_.policies())); |
49 } | 49 } |
50 | 50 |
51 TEST_F(ProxyPolicyProviderTest, Delegate) { | 51 TEST_F(ProxyPolicyProviderTest, Delegate) { |
52 PolicyBundle bundle; | 52 PolicyBundle bundle; |
53 bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 53 bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
54 .Set("policy", | 54 .Set("policy", |
55 POLICY_LEVEL_MANDATORY, | 55 POLICY_LEVEL_MANDATORY, |
56 POLICY_SCOPE_USER, | 56 POLICY_SCOPE_USER, |
57 base::Value::CreateStringValue("value"), | 57 new base::StringValue("value"), |
58 NULL); | 58 NULL); |
59 mock_provider_.UpdatePolicy(CopyBundle(bundle)); | 59 mock_provider_.UpdatePolicy(CopyBundle(bundle)); |
60 | 60 |
61 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); | 61 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); |
62 proxy_provider_.SetDelegate(&mock_provider_); | 62 proxy_provider_.SetDelegate(&mock_provider_); |
63 Mock::VerifyAndClearExpectations(&observer_); | 63 Mock::VerifyAndClearExpectations(&observer_); |
64 EXPECT_TRUE(bundle.Equals(proxy_provider_.policies())); | 64 EXPECT_TRUE(bundle.Equals(proxy_provider_.policies())); |
65 | 65 |
66 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); | 66 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); |
67 bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 67 bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
68 .Set("policy", | 68 .Set("policy", |
69 POLICY_LEVEL_MANDATORY, | 69 POLICY_LEVEL_MANDATORY, |
70 POLICY_SCOPE_USER, | 70 POLICY_SCOPE_USER, |
71 base::Value::CreateStringValue("new value"), | 71 new base::StringValue("new value"), |
72 NULL); | 72 NULL); |
73 mock_provider_.UpdatePolicy(CopyBundle(bundle)); | 73 mock_provider_.UpdatePolicy(CopyBundle(bundle)); |
74 Mock::VerifyAndClearExpectations(&observer_); | 74 Mock::VerifyAndClearExpectations(&observer_); |
75 EXPECT_TRUE(bundle.Equals(proxy_provider_.policies())); | 75 EXPECT_TRUE(bundle.Equals(proxy_provider_.policies())); |
76 | 76 |
77 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); | 77 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); |
78 proxy_provider_.SetDelegate(NULL); | 78 proxy_provider_.SetDelegate(NULL); |
79 EXPECT_TRUE(PolicyBundle().Equals(proxy_provider_.policies())); | 79 EXPECT_TRUE(PolicyBundle().Equals(proxy_provider_.policies())); |
80 } | 80 } |
81 | 81 |
(...skipping 11 matching lines...) Expand all Loading... |
93 proxy_provider_.RefreshPolicies(); | 93 proxy_provider_.RefreshPolicies(); |
94 Mock::VerifyAndClearExpectations(&observer_); | 94 Mock::VerifyAndClearExpectations(&observer_); |
95 Mock::VerifyAndClearExpectations(&mock_provider_); | 95 Mock::VerifyAndClearExpectations(&mock_provider_); |
96 | 96 |
97 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); | 97 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); |
98 mock_provider_.UpdatePolicy(scoped_ptr<PolicyBundle>(new PolicyBundle())); | 98 mock_provider_.UpdatePolicy(scoped_ptr<PolicyBundle>(new PolicyBundle())); |
99 Mock::VerifyAndClearExpectations(&observer_); | 99 Mock::VerifyAndClearExpectations(&observer_); |
100 } | 100 } |
101 | 101 |
102 } // namespace policy | 102 } // namespace policy |
OLD | NEW |