OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/user_cloud_policy_manager.h" | 5 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/sequenced_task_runner.h" | 9 #include "base/sequenced_task_runner.h" |
10 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" | 10 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" |
11 #include "components/policy/core/common/cloud/mock_user_cloud_policy_store.h" | 11 #include "components/policy/core/common/cloud/mock_user_cloud_policy_store.h" |
12 #include "components/policy/core/common/external_data_fetcher.h" | 12 #include "components/policy/core/common/external_data_fetcher.h" |
13 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 13 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
| 14 #include "components/policy/core/common/policy_types.h" |
14 #include "components/policy/core/common/schema_registry.h" | 15 #include "components/policy/core/common/schema_registry.h" |
15 #include "net/url_request/url_request_context_getter.h" | 16 #include "net/url_request/url_request_context_getter.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 namespace em = enterprise_management; | 20 namespace em = enterprise_management; |
20 | 21 |
21 using testing::AnyNumber; | 22 using testing::AnyNumber; |
22 using testing::AtLeast; | 23 using testing::AtLeast; |
23 using testing::Mock; | 24 using testing::Mock; |
24 using testing::_; | 25 using testing::_; |
25 | 26 |
26 namespace policy { | 27 namespace policy { |
27 namespace { | 28 namespace { |
28 | 29 |
29 class UserCloudPolicyManagerTest : public testing::Test { | 30 class UserCloudPolicyManagerTest : public testing::Test { |
30 protected: | 31 protected: |
31 UserCloudPolicyManagerTest() : store_(NULL) {} | 32 UserCloudPolicyManagerTest() : store_(NULL) {} |
32 | 33 |
33 void SetUp() override { | 34 void SetUp() override { |
34 // Set up a policy map for testing. | 35 // Set up a policy map for testing. |
35 policy_map_.Set("key", | 36 policy_map_.Set("key", |
36 POLICY_LEVEL_MANDATORY, | 37 POLICY_LEVEL_MANDATORY, |
37 POLICY_SCOPE_USER, | 38 POLICY_SCOPE_USER, |
| 39 POLICY_SOURCE_CLOUD, |
38 new base::StringValue("value"), | 40 new base::StringValue("value"), |
39 NULL); | 41 NULL); |
40 expected_bundle_.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 42 expected_bundle_.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
41 .CopyFrom(policy_map_); | 43 .CopyFrom(policy_map_); |
42 } | 44 } |
43 | 45 |
44 void TearDown() override { | 46 void TearDown() override { |
45 if (manager_) { | 47 if (manager_) { |
46 manager_->RemoveObserver(&observer_); | 48 manager_->RemoveObserver(&observer_); |
47 manager_->Shutdown(); | 49 manager_->Shutdown(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 store_->NotifyStoreLoaded(); | 88 store_->NotifyStoreLoaded(); |
87 EXPECT_TRUE(expected_bundle_.Equals(manager_->policies())); | 89 EXPECT_TRUE(expected_bundle_.Equals(manager_->policies())); |
88 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); | 90 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); |
89 EXPECT_CALL(*store_, Clear()); | 91 EXPECT_CALL(*store_, Clear()); |
90 manager_->DisconnectAndRemovePolicy(); | 92 manager_->DisconnectAndRemovePolicy(); |
91 EXPECT_FALSE(manager_->core()->service()); | 93 EXPECT_FALSE(manager_->core()->service()); |
92 } | 94 } |
93 | 95 |
94 } // namespace | 96 } // namespace |
95 } // namespace policy | 97 } // namespace policy |
OLD | NEW |