OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "components/policy/core/common/cloud/component_cloud_policy_service.h" | 5 #include "components/policy/core/common/cloud/component_cloud_policy_service.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } // namespace | 104 } // namespace |
105 | 105 |
106 class ComponentCloudPolicyServiceTest : public testing::Test { | 106 class ComponentCloudPolicyServiceTest : public testing::Test { |
107 protected: | 107 protected: |
108 ComponentCloudPolicyServiceTest() | 108 ComponentCloudPolicyServiceTest() |
109 : client_(NULL), | 109 : client_(NULL), |
110 core_(PolicyNamespaceKey(GetChromeUserPolicyType(), ""), | 110 core_(PolicyNamespaceKey(GetChromeUserPolicyType(), ""), |
111 &store_, | 111 &store_, |
112 loop_.message_loop_proxy()) {} | 112 loop_.message_loop_proxy()) {} |
113 | 113 |
114 virtual void SetUp() override { | 114 void SetUp() override { |
115 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 115 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
116 | 116 |
117 cache_ = new ResourceCache(temp_dir_.path(), loop_.message_loop_proxy()); | 117 cache_ = new ResourceCache(temp_dir_.path(), loop_.message_loop_proxy()); |
118 request_context_ = | 118 request_context_ = |
119 new TestURLRequestContextGetter(loop_.message_loop_proxy()); | 119 new TestURLRequestContextGetter(loop_.message_loop_proxy()); |
120 service_.reset(new ComponentCloudPolicyService( | 120 service_.reset(new ComponentCloudPolicyService( |
121 &delegate_, | 121 &delegate_, |
122 ®istry_, | 122 ®istry_, |
123 &core_, | 123 &core_, |
124 make_scoped_ptr(cache_), | 124 make_scoped_ptr(cache_), |
(...skipping 12 matching lines...) Expand all Loading... |
137 POLICY_SCOPE_USER, | 137 POLICY_SCOPE_USER, |
138 new base::StringValue("disabled"), | 138 new base::StringValue("disabled"), |
139 NULL); | 139 NULL); |
140 expected_policy_.Set("Second", | 140 expected_policy_.Set("Second", |
141 POLICY_LEVEL_RECOMMENDED, | 141 POLICY_LEVEL_RECOMMENDED, |
142 POLICY_SCOPE_USER, | 142 POLICY_SCOPE_USER, |
143 new base::StringValue("maybe"), | 143 new base::StringValue("maybe"), |
144 NULL); | 144 NULL); |
145 } | 145 } |
146 | 146 |
147 virtual void TearDown() override { | 147 void TearDown() override { |
148 // The service cleans up its backend on the background thread. | 148 // The service cleans up its backend on the background thread. |
149 service_.reset(); | 149 service_.reset(); |
150 RunUntilIdle(); | 150 RunUntilIdle(); |
151 } | 151 } |
152 | 152 |
153 void RunUntilIdle() { | 153 void RunUntilIdle() { |
154 base::RunLoop().RunUntilIdle(); | 154 base::RunLoop().RunUntilIdle(); |
155 } | 155 } |
156 | 156 |
157 void Connect(size_t expected_namespaces_in_client) { | 157 void Connect(size_t expected_namespaces_in_client) { |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, kTestExtension); | 556 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, kTestExtension); |
557 expected_bundle.Get(ns).Set("Name", | 557 expected_bundle.Get(ns).Set("Name", |
558 POLICY_LEVEL_MANDATORY, | 558 POLICY_LEVEL_MANDATORY, |
559 POLICY_SCOPE_USER, | 559 POLICY_SCOPE_USER, |
560 new base::StringValue("published"), | 560 new base::StringValue("published"), |
561 NULL); | 561 NULL); |
562 EXPECT_TRUE(service_->policy().Equals(expected_bundle)); | 562 EXPECT_TRUE(service_->policy().Equals(expected_bundle)); |
563 } | 563 } |
564 | 564 |
565 } // namespace policy | 565 } // namespace policy |
OLD | NEW |