| 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/async_policy_provider.h" | 5 #include "components/policy/core/common/async_policy_provider.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | |
| 11 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| 12 #include "base/values.h" | 11 #include "base/values.h" |
| 13 #include "components/policy/core/common/async_policy_loader.h" | 12 #include "components/policy/core/common/async_policy_loader.h" |
| 14 #include "components/policy/core/common/external_data_fetcher.h" | 13 #include "components/policy/core/common/external_data_fetcher.h" |
| 15 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 14 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
| 16 #include "components/policy/core/common/schema_registry.h" | 15 #include "components/policy/core/common/schema_registry.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 18 |
| 20 using testing::Mock; | 19 using testing::Mock; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 private: | 91 private: |
| 93 DISALLOW_COPY_AND_ASSIGN(AsyncPolicyProviderTest); | 92 DISALLOW_COPY_AND_ASSIGN(AsyncPolicyProviderTest); |
| 94 }; | 93 }; |
| 95 | 94 |
| 96 AsyncPolicyProviderTest::AsyncPolicyProviderTest() {} | 95 AsyncPolicyProviderTest::AsyncPolicyProviderTest() {} |
| 97 | 96 |
| 98 AsyncPolicyProviderTest::~AsyncPolicyProviderTest() {} | 97 AsyncPolicyProviderTest::~AsyncPolicyProviderTest() {} |
| 99 | 98 |
| 100 void AsyncPolicyProviderTest::SetUp() { | 99 void AsyncPolicyProviderTest::SetUp() { |
| 101 SetPolicy(&initial_bundle_, "policy", "initial"); | 100 SetPolicy(&initial_bundle_, "policy", "initial"); |
| 102 loader_ = new MockPolicyLoader(loop_.message_loop_proxy()); | 101 loader_ = new MockPolicyLoader(loop_.task_runner()); |
| 103 EXPECT_CALL(*loader_, LastModificationTime()) | 102 EXPECT_CALL(*loader_, LastModificationTime()) |
| 104 .WillRepeatedly(Return(base::Time())); | 103 .WillRepeatedly(Return(base::Time())); |
| 105 EXPECT_CALL(*loader_, InitOnBackgroundThread()).Times(1); | 104 EXPECT_CALL(*loader_, InitOnBackgroundThread()).Times(1); |
| 106 EXPECT_CALL(*loader_, MockLoad()).WillOnce(Return(&initial_bundle_)); | 105 EXPECT_CALL(*loader_, MockLoad()).WillOnce(Return(&initial_bundle_)); |
| 107 | 106 |
| 108 provider_.reset(new AsyncPolicyProvider( | 107 provider_.reset(new AsyncPolicyProvider( |
| 109 &schema_registry_, scoped_ptr<AsyncPolicyLoader>(loader_))); | 108 &schema_registry_, scoped_ptr<AsyncPolicyLoader>(loader_))); |
| 110 provider_->Init(&schema_registry_); | 109 provider_->Init(&schema_registry_); |
| 111 // Verify that the initial load is done synchronously: | 110 // Verify that the initial load is done synchronously: |
| 112 EXPECT_TRUE(provider_->policies().Equals(initial_bundle_)); | 111 EXPECT_TRUE(provider_->policies().Equals(initial_bundle_)); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0); | 217 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0); |
| 219 provider_->Shutdown(); | 218 provider_->Shutdown(); |
| 220 loop_.RunUntilIdle(); | 219 loop_.RunUntilIdle(); |
| 221 Mock::VerifyAndClearExpectations(&observer); | 220 Mock::VerifyAndClearExpectations(&observer); |
| 222 | 221 |
| 223 provider_->RemoveObserver(&observer); | 222 provider_->RemoveObserver(&observer); |
| 224 provider_.reset(); | 223 provider_.reset(); |
| 225 } | 224 } |
| 226 | 225 |
| 227 } // namespace policy | 226 } // namespace policy |
| OLD | NEW |