Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: chrome/browser/policy/configuration_policy_provider_test.h

Issue 8467011: Include only policy definitions that apply to the platfrom in the policy definition list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed dead declarations. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_TEST_H_
6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_TEST_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop.h"
15 #include "chrome/browser/policy/asynchronous_policy_test_base.h"
16 #include "content/test/test_browser_thread.h"
17 #include "policy/configuration_policy_type.h"
18 #include "testing/gtest/include/gtest/gtest.h"
19
20 namespace base {
21 class ListValue;
22 }
23
24 namespace policy {
25
26 class AsynchronousPolicyProvider;
27 struct PolicyDefinitionList;
28
29 // A stripped-down policy definition list that contains entries for the
30 // different policy setting types supported.
31 namespace test_policy_definitions {
32
33 // String policy keys.
34 extern const char kKeyString[];
35 extern const char kKeyBoolean[];
36 extern const char kKeyInteger[];
37 extern const char kKeyStringList[];
38
39 // Corresponding type constants.
40 extern const ConfigurationPolicyType kPolicyString;
41 extern const ConfigurationPolicyType kPolicyBoolean;
42 extern const ConfigurationPolicyType kPolicyInteger;
43 extern const ConfigurationPolicyType kPolicyStringList;
44
45 // Policy definition list that contains entries for the keys above.
46 extern const PolicyDefinitionList kList;
47
48 } // namespace test_policy_definitions
49
50 // An interface for creating a test policy provider and creating a policy
51 // provider instance for testing. Used as the parameter to the abstract
52 // ConfigurationPolicyProviderTest below.
53 class PolicyProviderTestHarness {
54 public:
55 PolicyProviderTestHarness();
56 virtual ~PolicyProviderTestHarness();
57
58 // Actions to run at gtest SetUp() time.
59 virtual void SetUp() = 0;
60
61 // Create a new policy provider.
62 virtual AsynchronousPolicyProvider* CreateProvider(
63 const PolicyDefinitionList* policy_definition_list) = 0;
64
65 // Helpers to configure the environment the policy provider reads from.
66 virtual void InstallEmptyPolicy() = 0;
67 virtual void InstallStringPolicy(const std::string& policy_name,
68 const std::string& policy_value) = 0;
69 virtual void InstallIntegerPolicy(const std::string& policy_name,
70 int policy_value) = 0;
71 virtual void InstallBooleanPolicy(const std::string& policy_name,
72 bool policy_value) = 0;
73 virtual void InstallStringListPolicy(const std::string& policy_name,
74 const ListValue* policy_value) = 0;
75
76 private:
77 DISALLOW_COPY_AND_ASSIGN(PolicyProviderTestHarness);
78 };
79
80 // A factory method for creating a test harness.
81 typedef PolicyProviderTestHarness* (*CreatePolicyProviderTestHarness)();
82
83 // Abstract policy provider test. This is meant to be instantiated for each
84 // policy provider implementation, passing in a suitable harness factory
85 // function as the test parameter.
86 class ConfigurationPolicyProviderTest
87 : public AsynchronousPolicyTestBase,
88 public testing::WithParamInterface<CreatePolicyProviderTestHarness> {
89 protected:
90 ConfigurationPolicyProviderTest();
91 virtual ~ConfigurationPolicyProviderTest();
92
93 virtual void SetUp();
94 virtual void TearDown();
95
96 // Installs a valid policy and checks whether the provider returns the
97 // |expected_value|.
98 void CheckValue(const char* policy_name,
99 ConfigurationPolicyType policy_type,
100 const base::Value& expected_value,
101 base::Closure install_value);
102
103 scoped_ptr<PolicyProviderTestHarness> test_harness_;
104 scoped_ptr<AsynchronousPolicyProvider> provider_;
105
106 private:
107 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderTest);
108 };
109
110 } // namespace policy
111
112 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_TEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698