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/policy_types.h" |
9 #include "components/policy/core/common/proxy_policy_provider.h" | 10 #include "components/policy/core/common/proxy_policy_provider.h" |
10 #include "components/policy/core/common/schema_registry.h" | 11 #include "components/policy/core/common/schema_registry.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 using testing::Mock; | 15 using testing::Mock; |
15 | 16 |
16 namespace policy { | 17 namespace policy { |
17 | 18 |
18 class ProxyPolicyProviderTest : public testing::Test { | 19 class ProxyPolicyProviderTest : public testing::Test { |
(...skipping 29 matching lines...) Expand all Loading... |
48 EXPECT_TRUE(proxy_provider_.IsInitializationComplete(POLICY_DOMAIN_CHROME)); | 49 EXPECT_TRUE(proxy_provider_.IsInitializationComplete(POLICY_DOMAIN_CHROME)); |
49 EXPECT_TRUE(PolicyBundle().Equals(proxy_provider_.policies())); | 50 EXPECT_TRUE(PolicyBundle().Equals(proxy_provider_.policies())); |
50 } | 51 } |
51 | 52 |
52 TEST_F(ProxyPolicyProviderTest, Delegate) { | 53 TEST_F(ProxyPolicyProviderTest, Delegate) { |
53 PolicyBundle bundle; | 54 PolicyBundle bundle; |
54 bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 55 bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
55 .Set("policy", | 56 .Set("policy", |
56 POLICY_LEVEL_MANDATORY, | 57 POLICY_LEVEL_MANDATORY, |
57 POLICY_SCOPE_USER, | 58 POLICY_SCOPE_USER, |
| 59 POLICY_SOURCE_CLOUD, |
58 new base::StringValue("value"), | 60 new base::StringValue("value"), |
59 NULL); | 61 NULL); |
60 mock_provider_.UpdatePolicy(CopyBundle(bundle)); | 62 mock_provider_.UpdatePolicy(CopyBundle(bundle)); |
61 | 63 |
62 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); | 64 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); |
63 proxy_provider_.SetDelegate(&mock_provider_); | 65 proxy_provider_.SetDelegate(&mock_provider_); |
64 Mock::VerifyAndClearExpectations(&observer_); | 66 Mock::VerifyAndClearExpectations(&observer_); |
65 EXPECT_TRUE(bundle.Equals(proxy_provider_.policies())); | 67 EXPECT_TRUE(bundle.Equals(proxy_provider_.policies())); |
66 | 68 |
67 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); | 69 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); |
68 bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 70 bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
69 .Set("policy", | 71 .Set("policy", |
70 POLICY_LEVEL_MANDATORY, | 72 POLICY_LEVEL_MANDATORY, |
71 POLICY_SCOPE_USER, | 73 POLICY_SCOPE_USER, |
| 74 POLICY_SOURCE_CLOUD, |
72 new base::StringValue("new value"), | 75 new base::StringValue("new value"), |
73 NULL); | 76 NULL); |
74 mock_provider_.UpdatePolicy(CopyBundle(bundle)); | 77 mock_provider_.UpdatePolicy(CopyBundle(bundle)); |
75 Mock::VerifyAndClearExpectations(&observer_); | 78 Mock::VerifyAndClearExpectations(&observer_); |
76 EXPECT_TRUE(bundle.Equals(proxy_provider_.policies())); | 79 EXPECT_TRUE(bundle.Equals(proxy_provider_.policies())); |
77 | 80 |
78 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); | 81 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); |
79 proxy_provider_.SetDelegate(NULL); | 82 proxy_provider_.SetDelegate(NULL); |
80 EXPECT_TRUE(PolicyBundle().Equals(proxy_provider_.policies())); | 83 EXPECT_TRUE(PolicyBundle().Equals(proxy_provider_.policies())); |
81 } | 84 } |
(...skipping 12 matching lines...) Expand all Loading... |
94 proxy_provider_.RefreshPolicies(); | 97 proxy_provider_.RefreshPolicies(); |
95 Mock::VerifyAndClearExpectations(&observer_); | 98 Mock::VerifyAndClearExpectations(&observer_); |
96 Mock::VerifyAndClearExpectations(&mock_provider_); | 99 Mock::VerifyAndClearExpectations(&mock_provider_); |
97 | 100 |
98 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); | 101 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)); |
99 mock_provider_.UpdatePolicy(scoped_ptr<PolicyBundle>(new PolicyBundle())); | 102 mock_provider_.UpdatePolicy(scoped_ptr<PolicyBundle>(new PolicyBundle())); |
100 Mock::VerifyAndClearExpectations(&observer_); | 103 Mock::VerifyAndClearExpectations(&observer_); |
101 } | 104 } |
102 | 105 |
103 } // namespace policy | 106 } // namespace policy |
OLD | NEW |