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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_POLICY_CORE_COMMON_MOCK_CONFIGURATION_POLICY_PROVIDER_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_MOCK_CONFIGURATION_POLICY_PROVIDER_H_
8 #include "base/basictypes.h"
9 #include "components/policy/core/common/configuration_policy_provider.h"
10 #include "components/policy/core/common/policy_map.h"
11 #include "components/policy/core/common/schema_registry.h"
12 #include "testing/gmock/include/gmock/gmock.h"
16 // Mock ConfigurationPolicyProvider implementation that supplies canned
17 // values for polices.
18 // TODO(joaodasilva, mnissler): introduce an implementation that non-policy
19 // code can use that doesn't require the usual boilerplate.
20 // http://crbug.com/242087
21 class MockConfigurationPolicyProvider
: public ConfigurationPolicyProvider
{
23 MockConfigurationPolicyProvider();
24 virtual ~MockConfigurationPolicyProvider();
26 MOCK_CONST_METHOD1(IsInitializationComplete
, bool(PolicyDomain domain
));
27 MOCK_METHOD0(RefreshPolicies
, void());
29 // Make public for tests.
30 using ConfigurationPolicyProvider::UpdatePolicy
;
32 // Utility method that invokes UpdatePolicy() with a PolicyBundle that maps
33 // the Chrome namespace to a copy of |policy|.
34 void UpdateChromePolicy(const PolicyMap
& policy
);
36 // Convenience method so that tests don't need to create a registry to create
38 using ConfigurationPolicyProvider::Init
;
40 ConfigurationPolicyProvider::Init(®istry_
);
43 // Convenience method that installs an expectation on RefreshPolicies that
44 // just notifies the observers and serves the same policies.
45 void SetAutoRefresh();
48 void RefreshWithSamePolicies();
50 SchemaRegistry registry_
;
52 DISALLOW_COPY_AND_ASSIGN(MockConfigurationPolicyProvider
);
55 class MockConfigurationPolicyObserver
56 : public ConfigurationPolicyProvider::Observer
{
58 MockConfigurationPolicyObserver();
59 virtual ~MockConfigurationPolicyObserver();
61 MOCK_METHOD1(OnUpdatePolicy
, void(ConfigurationPolicyProvider
*));
66 #endif // COMPONENTS_POLICY_CORE_COMMON_MOCK_CONFIGURATION_POLICY_PROVIDER_H_