| 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/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 using testing::Mock; | 24 using testing::Mock; |
| 25 using testing::_; | 25 using testing::_; |
| 26 | 26 |
| 27 namespace policy { | 27 namespace policy { |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 class UserCloudPolicyManagerTest : public testing::Test { | 30 class UserCloudPolicyManagerTest : public testing::Test { |
| 31 protected: | 31 protected: |
| 32 UserCloudPolicyManagerTest() : store_(NULL) {} | 32 UserCloudPolicyManagerTest() : store_(NULL) {} |
| 33 | 33 |
| 34 virtual void SetUp() override { | 34 void SetUp() override { |
| 35 // Set up a policy map for testing. | 35 // Set up a policy map for testing. |
| 36 policy_map_.Set("key", | 36 policy_map_.Set("key", |
| 37 POLICY_LEVEL_MANDATORY, | 37 POLICY_LEVEL_MANDATORY, |
| 38 POLICY_SCOPE_USER, | 38 POLICY_SCOPE_USER, |
| 39 new base::StringValue("value"), | 39 new base::StringValue("value"), |
| 40 NULL); | 40 NULL); |
| 41 expected_bundle_.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 41 expected_bundle_.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
| 42 .CopyFrom(policy_map_); | 42 .CopyFrom(policy_map_); |
| 43 } | 43 } |
| 44 | 44 |
| 45 virtual void TearDown() override { | 45 void TearDown() override { |
| 46 if (manager_) { | 46 if (manager_) { |
| 47 manager_->RemoveObserver(&observer_); | 47 manager_->RemoveObserver(&observer_); |
| 48 manager_->Shutdown(); | 48 manager_->Shutdown(); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 void CreateManager() { | 52 void CreateManager() { |
| 53 store_ = new MockUserCloudPolicyStore(); | 53 store_ = new MockUserCloudPolicyStore(); |
| 54 EXPECT_CALL(*store_, Load()); | 54 EXPECT_CALL(*store_, Load()); |
| 55 manager_.reset(new UserCloudPolicyManager( | 55 manager_.reset(new UserCloudPolicyManager( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 store_->NotifyStoreLoaded(); | 90 store_->NotifyStoreLoaded(); |
| 91 EXPECT_TRUE(expected_bundle_.Equals(manager_->policies())); | 91 EXPECT_TRUE(expected_bundle_.Equals(manager_->policies())); |
| 92 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); | 92 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); |
| 93 EXPECT_CALL(*store_, Clear()); | 93 EXPECT_CALL(*store_, Clear()); |
| 94 manager_->DisconnectAndRemovePolicy(); | 94 manager_->DisconnectAndRemovePolicy(); |
| 95 EXPECT_FALSE(manager_->core()->service()); | 95 EXPECT_FALSE(manager_->core()->service()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 } // namespace | 98 } // namespace |
| 99 } // namespace policy | 99 } // namespace policy |
| OLD | NEW |