| 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" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 class MockPolicyLoader : public AsyncPolicyLoader { | 40 class MockPolicyLoader : public AsyncPolicyLoader { |
| 41 public: | 41 public: |
| 42 explicit MockPolicyLoader( | 42 explicit MockPolicyLoader( |
| 43 scoped_refptr<base::SequencedTaskRunner> task_runner); | 43 scoped_refptr<base::SequencedTaskRunner> task_runner); |
| 44 virtual ~MockPolicyLoader(); | 44 virtual ~MockPolicyLoader(); |
| 45 | 45 |
| 46 // Load() returns a scoped_ptr<PolicyBundle> but it can't be mocked because | 46 // Load() returns a scoped_ptr<PolicyBundle> but it can't be mocked because |
| 47 // scoped_ptr is moveable but not copyable. This override forwards the | 47 // scoped_ptr is moveable but not copyable. This override forwards the |
| 48 // call to MockLoad() which returns a PolicyBundle*, and returns a copy | 48 // call to MockLoad() which returns a PolicyBundle*, and returns a copy |
| 49 // wrapped in a passed scoped_ptr. | 49 // wrapped in a passed scoped_ptr. |
| 50 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE; | 50 virtual scoped_ptr<PolicyBundle> Load() override; |
| 51 | 51 |
| 52 MOCK_METHOD0(MockLoad, const PolicyBundle*()); | 52 MOCK_METHOD0(MockLoad, const PolicyBundle*()); |
| 53 MOCK_METHOD0(InitOnBackgroundThread, void()); | 53 MOCK_METHOD0(InitOnBackgroundThread, void()); |
| 54 MOCK_METHOD0(LastModificationTime, base::Time()); | 54 MOCK_METHOD0(LastModificationTime, base::Time()); |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 DISALLOW_COPY_AND_ASSIGN(MockPolicyLoader); | 57 DISALLOW_COPY_AND_ASSIGN(MockPolicyLoader); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 MockPolicyLoader::MockPolicyLoader( | 60 MockPolicyLoader::MockPolicyLoader( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 73 return bundle.Pass(); | 73 return bundle.Pass(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 } // namespace | 76 } // namespace |
| 77 | 77 |
| 78 class AsyncPolicyProviderTest : public testing::Test { | 78 class AsyncPolicyProviderTest : public testing::Test { |
| 79 protected: | 79 protected: |
| 80 AsyncPolicyProviderTest(); | 80 AsyncPolicyProviderTest(); |
| 81 virtual ~AsyncPolicyProviderTest(); | 81 virtual ~AsyncPolicyProviderTest(); |
| 82 | 82 |
| 83 virtual void SetUp() OVERRIDE; | 83 virtual void SetUp() override; |
| 84 virtual void TearDown() OVERRIDE; | 84 virtual void TearDown() override; |
| 85 | 85 |
| 86 base::MessageLoop loop_; | 86 base::MessageLoop loop_; |
| 87 SchemaRegistry schema_registry_; | 87 SchemaRegistry schema_registry_; |
| 88 PolicyBundle initial_bundle_; | 88 PolicyBundle initial_bundle_; |
| 89 MockPolicyLoader* loader_; | 89 MockPolicyLoader* loader_; |
| 90 scoped_ptr<AsyncPolicyProvider> provider_; | 90 scoped_ptr<AsyncPolicyProvider> provider_; |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 DISALLOW_COPY_AND_ASSIGN(AsyncPolicyProviderTest); | 93 DISALLOW_COPY_AND_ASSIGN(AsyncPolicyProviderTest); |
| 94 }; | 94 }; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0); | 218 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0); |
| 219 provider_->Shutdown(); | 219 provider_->Shutdown(); |
| 220 loop_.RunUntilIdle(); | 220 loop_.RunUntilIdle(); |
| 221 Mock::VerifyAndClearExpectations(&observer); | 221 Mock::VerifyAndClearExpectations(&observer); |
| 222 | 222 |
| 223 provider_->RemoveObserver(&observer); | 223 provider_->RemoveObserver(&observer); |
| 224 provider_.reset(); | 224 provider_.reset(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 } // namespace policy | 227 } // namespace policy |
| OLD | NEW |