| 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 23 matching lines...) Expand all Loading... |
| 34 POLICY_LEVEL_MANDATORY, | 34 POLICY_LEVEL_MANDATORY, |
| 35 POLICY_SCOPE_USER, | 35 POLICY_SCOPE_USER, |
| 36 new base::StringValue(value), | 36 new base::StringValue(value), |
| 37 NULL); | 37 NULL); |
| 38 } | 38 } |
| 39 | 39 |
| 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 ~MockPolicyLoader() override; |
| 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 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 157 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 |