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