Index: chrome/browser/policy/mock_configuration_policy_provider.h |
diff --git a/chrome/browser/policy/mock_configuration_policy_provider.h b/chrome/browser/policy/mock_configuration_policy_provider.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..135ea3f217dd09c86c9e48642c0343f646c8a365 |
--- /dev/null |
+++ b/chrome/browser/policy/mock_configuration_policy_provider.h |
@@ -0,0 +1,66 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_POLICY_MOCK_CONFIGURATION_POLICY_PROVIDER_H_ |
+#define CHROME_BROWSER_POLICY_MOCK_CONFIGURATION_POLICY_PROVIDER_H_ |
+ |
+#include "base/basictypes.h" |
+#include "chrome/browser/policy/configuration_policy_provider.h" |
+#include "components/policy/core/common/policy_map.h" |
+#include "components/policy/core/common/schema_registry.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
+ |
+namespace policy { |
+ |
+// Mock ConfigurationPolicyProvider implementation that supplies canned |
+// values for polices. |
+// TODO(joaodasilva, mnissler): introduce an implementation that non-policy |
+// code can use that doesn't require the usual boilerplate. |
+// http://crbug.com/242087 |
+class MockConfigurationPolicyProvider : public ConfigurationPolicyProvider { |
+ public: |
+ MockConfigurationPolicyProvider(); |
+ virtual ~MockConfigurationPolicyProvider(); |
+ |
+ MOCK_CONST_METHOD1(IsInitializationComplete, bool(PolicyDomain domain)); |
+ MOCK_METHOD0(RefreshPolicies, void()); |
+ |
+ // Make public for tests. |
+ using ConfigurationPolicyProvider::UpdatePolicy; |
+ |
+ // Utility method that invokes UpdatePolicy() with a PolicyBundle that maps |
+ // the Chrome namespace to a copy of |policy|. |
+ void UpdateChromePolicy(const PolicyMap& policy); |
+ |
+ // Convenience method so that tests don't need to create a registry to create |
+ // this mock. |
+ using ConfigurationPolicyProvider::Init; |
+ void Init() { |
+ ConfigurationPolicyProvider::Init(®istry_); |
+ } |
+ |
+ // Convenience method that installs an expectation on RefreshPolicies that |
+ // just notifies the observers and serves the same policies. |
+ void SetAutoRefresh(); |
+ |
+ private: |
+ void RefreshWithSamePolicies(); |
+ |
+ SchemaRegistry registry_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MockConfigurationPolicyProvider); |
+}; |
+ |
+class MockConfigurationPolicyObserver |
+ : public ConfigurationPolicyProvider::Observer { |
+ public: |
+ MockConfigurationPolicyObserver(); |
+ virtual ~MockConfigurationPolicyObserver(); |
+ |
+ MOCK_METHOD1(OnUpdatePolicy, void(ConfigurationPolicyProvider*)); |
+}; |
+ |
+} // namespace policy |
+ |
+#endif // CHROME_BROWSER_POLICY_MOCK_CONFIGURATION_POLICY_PROVIDER_H_ |