Chromium Code Reviews| 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/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "components/policy/core/common/async_policy_loader.h" | 12 #include "components/policy/core/common/async_policy_loader.h" |
| 13 #include "components/policy/core/common/external_data_fetcher.h" | 13 #include "components/policy/core/common/external_data_fetcher.h" |
| 14 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 14 #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" | |
|
bartfab (slow)
2015/09/16 15:58:41
Nit: Duplicate include.
fhorschig
2015/09/17 11:20:41
Done. (Arrggh!)
| |
| 15 #include "components/policy/core/common/schema_registry.h" | 17 #include "components/policy/core/common/schema_registry.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 20 |
| 19 using testing::Mock; | 21 using testing::Mock; |
| 20 using testing::Return; | 22 using testing::Return; |
| 21 using testing::Sequence; | 23 using testing::Sequence; |
| 22 | 24 |
| 23 namespace policy { | 25 namespace policy { |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| 26 | 28 |
| 27 // Helper to write a policy in |bundle| with less code. | 29 // Helper to write a policy in |bundle| with less code. |
| 28 void SetPolicy(PolicyBundle* bundle, | 30 void SetPolicy(PolicyBundle* bundle, |
| 29 const std::string& name, | 31 const std::string& name, |
| 30 const std::string& value) { | 32 const std::string& value) { |
| 31 bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 33 bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
| 32 .Set(name, | 34 .Set(name, |
| 33 POLICY_LEVEL_MANDATORY, | 35 POLICY_LEVEL_MANDATORY, |
| 34 POLICY_SCOPE_USER, | 36 POLICY_SCOPE_USER, |
| 37 POLICY_SOURCE_PLATFORM, | |
| 35 new base::StringValue(value), | 38 new base::StringValue(value), |
| 36 NULL); | 39 NULL); |
| 37 } | 40 } |
| 38 | 41 |
| 39 class MockPolicyLoader : public AsyncPolicyLoader { | 42 class MockPolicyLoader : public AsyncPolicyLoader { |
| 40 public: | 43 public: |
| 41 explicit MockPolicyLoader( | 44 explicit MockPolicyLoader( |
| 42 scoped_refptr<base::SequencedTaskRunner> task_runner); | 45 scoped_refptr<base::SequencedTaskRunner> task_runner); |
| 43 ~MockPolicyLoader() override; | 46 ~MockPolicyLoader() override; |
| 44 | 47 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0); | 220 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0); |
| 218 provider_->Shutdown(); | 221 provider_->Shutdown(); |
| 219 loop_.RunUntilIdle(); | 222 loop_.RunUntilIdle(); |
| 220 Mock::VerifyAndClearExpectations(&observer); | 223 Mock::VerifyAndClearExpectations(&observer); |
| 221 | 224 |
| 222 provider_->RemoveObserver(&observer); | 225 provider_->RemoveObserver(&observer); |
| 223 provider_.reset(); | 226 provider_.reset(); |
| 224 } | 227 } |
| 225 | 228 |
| 226 } // namespace policy | 229 } // namespace policy |
| OLD | NEW |