OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/json/json_value_serializer.h" | 8 #include "base/json/json_value_serializer.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
Joao da Silva
2011/11/07 13:06:17
Nit: not used
Mattias Nissler (ping if slow)
2011/11/09 14:37:27
Done.
| |
10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/values.h" | |
12 #include "chrome/browser/policy/config_dir_policy_provider.h" | 13 #include "chrome/browser/policy/config_dir_policy_provider.h" |
13 #include "chrome/browser/policy/configuration_policy_pref_store.h" | |
14 #include "chrome/browser/policy/policy_map.h" | 14 #include "chrome/browser/policy/policy_map.h" |
15 #include "content/test/test_browser_thread.h" | |
16 #include "policy/policy_constants.h" | 15 #include "policy/policy_constants.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
18 | 17 |
19 using content::BrowserThread; | |
20 | |
21 namespace policy { | 18 namespace policy { |
22 | 19 |
23 template<typename BASE> | 20 namespace { |
24 class ConfigDirPolicyProviderTestBase : public BASE { | 21 |
22 // A stripped-down policy definition list for testing that contains an entry for | |
23 // each of the supported value types. | |
24 const PolicyDefinitionList::Entry kTestPolicyDefinitionListEntries[] = { | |
25 { kPolicyHomepageLocation, base::Value::TYPE_STRING, "StringPolicy" }, | |
26 { kPolicyHomepageIsNewTabPage, base::Value::TYPE_BOOLEAN, "BooleanPolicy" }, | |
27 { kPolicyRestoreOnStartup, base::Value::TYPE_INTEGER, "IntegerPolicy" }, | |
28 { kPolicyRestoreOnStartupURLs, base::Value::TYPE_LIST, "StringListPolicy" }, | |
29 }; | |
30 | |
31 const PolicyDefinitionList kTestPolicyDefinitionList = { | |
32 kTestPolicyDefinitionListEntries, | |
33 kTestPolicyDefinitionListEntries + arraysize(kTestPolicyDefinitionListEntries) | |
34 }; | |
35 | |
36 } // namespace | |
37 | |
38 class ConfigDirPolicyProviderTest : public testing::Test { | |
25 protected: | 39 protected: |
26 ConfigDirPolicyProviderTestBase() {} | 40 ConfigDirPolicyProviderTest() {} |
27 | 41 |
28 virtual void SetUp() { | 42 virtual void SetUp() { |
29 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); | 43 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); |
30 } | 44 } |
31 | 45 |
32 // JSON-encode a dictionary and write it to a file. | 46 // JSON-encode a dictionary and write it to a file. |
33 void WriteConfigFile(const DictionaryValue& dict, | 47 void WriteConfigFile(const base::DictionaryValue& dict, |
34 const std::string& file_name) { | 48 const std::string& file_name) { |
35 std::string data; | 49 std::string data; |
36 JSONStringValueSerializer serializer(&data); | 50 JSONStringValueSerializer serializer(&data); |
37 serializer.Serialize(dict); | 51 serializer.Serialize(dict); |
38 const FilePath file_path(test_dir().AppendASCII(file_name)); | 52 const FilePath file_path(test_dir().AppendASCII(file_name)); |
39 ASSERT_TRUE(file_util::WriteFile(file_path, data.c_str(), data.size())); | 53 ASSERT_TRUE(file_util::WriteFile(file_path, data.c_str(), data.size())); |
40 } | 54 } |
41 | 55 |
56 void CheckValue(const std::string& name, | |
57 ConfigurationPolicyType policy_type, | |
58 const base::Value& test_value) { | |
59 base::DictionaryValue dict; | |
60 dict.Set(name, test_value.DeepCopy()); | |
61 WriteConfigFile(dict, "policy"); | |
62 ConfigDirPolicyProvider provider(&kTestPolicyDefinitionList, test_dir()); | |
63 PolicyMap policy_map; | |
64 EXPECT_TRUE(provider.Provide(&policy_map)); | |
65 EXPECT_EQ(1U, policy_map.size()); | |
66 const base::Value* value = policy_map.Get(policy_type); | |
67 EXPECT_TRUE(base::Value::Equals(&test_value, value)); | |
68 } | |
69 | |
42 const FilePath& test_dir() { return test_dir_.path(); } | 70 const FilePath& test_dir() { return test_dir_.path(); } |
43 | 71 |
44 private: | 72 private: |
45 ScopedTempDir test_dir_; | 73 ScopedTempDir test_dir_; |
46 }; | 74 }; |
47 | 75 |
48 class ConfigDirPolicyLoaderTest | |
49 : public ConfigDirPolicyProviderTestBase<testing::Test> { | |
50 }; | |
51 | |
52 // The preferences dictionary is expected to be empty when there are no files to | 76 // The preferences dictionary is expected to be empty when there are no files to |
53 // load. | 77 // load. |
54 TEST_F(ConfigDirPolicyLoaderTest, ReadPrefsEmpty) { | 78 TEST_F(ConfigDirPolicyProviderTest, ReadPrefsEmpty) { |
55 ConfigDirPolicyProviderDelegate loader(test_dir()); | 79 ConfigDirPolicyProviderDelegate loader(test_dir()); |
56 scoped_ptr<DictionaryValue> policy(loader.Load()); | 80 scoped_ptr<base::DictionaryValue> policy(loader.Load()); |
57 EXPECT_TRUE(policy.get()); | 81 EXPECT_TRUE(policy.get()); |
58 EXPECT_TRUE(policy->empty()); | 82 EXPECT_TRUE(policy->empty()); |
59 } | 83 } |
60 | 84 |
61 // Reading from a non-existent directory should result in an empty preferences | 85 // Reading from a non-existent directory should result in an empty preferences |
62 // dictionary. | 86 // dictionary. |
63 TEST_F(ConfigDirPolicyLoaderTest, ReadPrefsNonExistentDirectory) { | 87 TEST_F(ConfigDirPolicyProviderTest, ReadPrefsNonExistentDirectory) { |
64 FilePath non_existent_dir(test_dir().Append(FILE_PATH_LITERAL("not_there"))); | 88 FilePath non_existent_dir(test_dir().Append(FILE_PATH_LITERAL("not_there"))); |
65 ConfigDirPolicyProviderDelegate loader(non_existent_dir); | 89 ConfigDirPolicyProviderDelegate loader(non_existent_dir); |
66 scoped_ptr<DictionaryValue> policy(loader.Load()); | 90 scoped_ptr<base::DictionaryValue> policy(loader.Load()); |
67 EXPECT_TRUE(policy.get()); | 91 EXPECT_TRUE(policy.get()); |
68 EXPECT_TRUE(policy->empty()); | 92 EXPECT_TRUE(policy->empty()); |
69 } | 93 } |
70 | 94 |
71 // Test reading back a single preference value. | 95 // Test reading back a single preference value. |
72 TEST_F(ConfigDirPolicyLoaderTest, ReadPrefsSinglePref) { | 96 TEST_F(ConfigDirPolicyProviderTest, ReadPrefsSinglePref) { |
73 DictionaryValue test_dict; | 97 base::DictionaryValue test_dict; |
74 test_dict.SetString("HomepageLocation", "http://www.google.com"); | 98 test_dict.SetString("HomepageLocation", "http://www.google.com"); |
75 WriteConfigFile(test_dict, "config_file"); | 99 WriteConfigFile(test_dict, "config_file"); |
76 | 100 |
77 ConfigDirPolicyProviderDelegate loader(test_dir()); | 101 ConfigDirPolicyProviderDelegate loader(test_dir()); |
78 scoped_ptr<DictionaryValue> policy(loader.Load()); | 102 scoped_ptr<base::DictionaryValue> policy(loader.Load()); |
79 EXPECT_TRUE(policy.get()); | 103 EXPECT_TRUE(policy.get()); |
80 EXPECT_TRUE(policy->Equals(&test_dict)); | 104 EXPECT_TRUE(policy->Equals(&test_dict)); |
81 } | 105 } |
82 | 106 |
83 // Test merging values from different files. | 107 // Test merging values from different files. |
84 TEST_F(ConfigDirPolicyLoaderTest, ReadPrefsMergePrefs) { | 108 TEST_F(ConfigDirPolicyProviderTest, ReadPrefsMergePrefs) { |
85 // Write a bunch of data files in order to increase the chance to detect the | 109 // Write a bunch of data files in order to increase the chance to detect the |
86 // provider not respecting lexicographic ordering when reading them. Since the | 110 // provider not respecting lexicographic ordering when reading them. Since the |
87 // filesystem may return files in arbitrary order, there is no way to be sure, | 111 // filesystem may return files in arbitrary order, there is no way to be sure, |
88 // but this is better than nothing. | 112 // but this is better than nothing. |
89 DictionaryValue test_dict_bar; | 113 base::DictionaryValue test_dict_bar; |
90 test_dict_bar.SetString("HomepageLocation", "http://bar.com"); | 114 test_dict_bar.SetString("HomepageLocation", "http://bar.com"); |
91 for (unsigned int i = 1; i <= 4; ++i) | 115 for (unsigned int i = 1; i <= 4; ++i) |
92 WriteConfigFile(test_dict_bar, base::IntToString(i)); | 116 WriteConfigFile(test_dict_bar, base::IntToString(i)); |
93 DictionaryValue test_dict_foo; | 117 base::DictionaryValue test_dict_foo; |
94 test_dict_foo.SetString("HomepageLocation", "http://foo.com"); | 118 test_dict_foo.SetString("HomepageLocation", "http://foo.com"); |
95 WriteConfigFile(test_dict_foo, "9"); | 119 WriteConfigFile(test_dict_foo, "9"); |
96 for (unsigned int i = 5; i <= 8; ++i) | 120 for (unsigned int i = 5; i <= 8; ++i) |
97 WriteConfigFile(test_dict_bar, base::IntToString(i)); | 121 WriteConfigFile(test_dict_bar, base::IntToString(i)); |
98 | 122 |
99 ConfigDirPolicyProviderDelegate loader(test_dir()); | 123 ConfigDirPolicyProviderDelegate loader(test_dir()); |
100 scoped_ptr<DictionaryValue> policy(loader.Load()); | 124 scoped_ptr<base::DictionaryValue> policy(loader.Load()); |
101 EXPECT_TRUE(policy.get()); | 125 EXPECT_TRUE(policy.get()); |
102 EXPECT_TRUE(policy->Equals(&test_dict_foo)); | 126 EXPECT_TRUE(policy->Equals(&test_dict_foo)); |
103 } | 127 } |
104 | 128 |
105 // Holds policy type, corresponding policy key string and a valid value for use | 129 TEST_F(ConfigDirPolicyProviderTest, Default) { |
106 // in parametrized value tests. | 130 ConfigDirPolicyProvider provider(&kTestPolicyDefinitionList, test_dir()); |
107 class ValueTestParams { | |
108 public: | |
109 // Assumes ownership of |test_value|. | |
110 ValueTestParams(ConfigurationPolicyType type, | |
111 const char* policy_key, | |
112 Value* test_value) | |
113 : type_(type), | |
114 policy_key_(policy_key), | |
115 test_value_(test_value) {} | |
116 | |
117 // testing::TestWithParam does copying, so provide copy constructor and | |
118 // assignment operator. | |
119 ValueTestParams(const ValueTestParams& other) | |
120 : type_(other.type_), | |
121 policy_key_(other.policy_key_), | |
122 test_value_(other.test_value_->DeepCopy()) {} | |
123 | |
124 const ValueTestParams& operator=(ValueTestParams other) { | |
125 swap(other); | |
126 return *this; | |
127 } | |
128 | |
129 void swap(ValueTestParams& other) { | |
130 std::swap(type_, other.type_); | |
131 std::swap(policy_key_, other.policy_key_); | |
132 test_value_.swap(other.test_value_); | |
133 } | |
134 | |
135 ConfigurationPolicyType type() const { return type_; } | |
136 const char* policy_key() const { return policy_key_; } | |
137 const Value* test_value() const { return test_value_.get(); } | |
138 | |
139 // Factory methods that create parameter objects for different value types. | |
140 static ValueTestParams ForStringPolicy( | |
141 ConfigurationPolicyType type, | |
142 const char* policy_key) { | |
143 return ValueTestParams(type, policy_key, Value::CreateStringValue("test")); | |
144 } | |
145 static ValueTestParams ForBooleanPolicy( | |
146 ConfigurationPolicyType type, | |
147 const char* policy_key) { | |
148 return ValueTestParams(type, policy_key, Value::CreateBooleanValue(true)); | |
149 } | |
150 static ValueTestParams ForIntegerPolicy( | |
151 ConfigurationPolicyType type, | |
152 const char* policy_key) { | |
153 return ValueTestParams(type, policy_key, Value::CreateIntegerValue(42)); | |
154 } | |
155 static ValueTestParams ForListPolicy( | |
156 ConfigurationPolicyType type, | |
157 const char* policy_key) { | |
158 ListValue* value = new ListValue(); | |
159 value->Set(0U, Value::CreateStringValue("first")); | |
160 value->Set(1U, Value::CreateStringValue("second")); | |
161 return ValueTestParams(type, policy_key, value); | |
162 } | |
163 | |
164 private: | |
165 ConfigurationPolicyType type_; | |
166 const char* policy_key_; | |
167 scoped_ptr<Value> test_value_; | |
168 }; | |
169 | |
170 // Tests whether the provider correctly reads a value from the file and forwards | |
171 // it to the store. | |
172 class ConfigDirPolicyProviderValueTest | |
173 : public ConfigDirPolicyProviderTestBase< | |
174 testing::TestWithParam<ValueTestParams> > { | |
175 protected: | |
176 ConfigDirPolicyProviderValueTest() | |
177 : ui_thread_(BrowserThread::UI, &loop_), | |
178 file_thread_(BrowserThread::FILE, &loop_) {} | |
179 | |
180 virtual void TearDown() { | |
181 loop_.RunAllPending(); | |
182 } | |
183 | |
184 private: | |
185 MessageLoop loop_; | |
186 content::TestBrowserThread ui_thread_; | |
187 content::TestBrowserThread file_thread_; | |
188 }; | |
189 | |
190 TEST_P(ConfigDirPolicyProviderValueTest, Default) { | |
191 ConfigDirPolicyProvider provider(GetChromePolicyDefinitionList(), test_dir()); | |
192 PolicyMap policy_map; | 131 PolicyMap policy_map; |
193 EXPECT_TRUE(provider.Provide(&policy_map)); | 132 EXPECT_TRUE(provider.Provide(&policy_map)); |
194 EXPECT_TRUE(policy_map.empty()); | 133 EXPECT_TRUE(policy_map.empty()); |
195 } | 134 } |
196 | 135 |
197 TEST_P(ConfigDirPolicyProviderValueTest, TestValue) { | 136 TEST_F(ConfigDirPolicyProviderTest, TestStringPolicy) { |
198 DictionaryValue dict; | 137 base::FundamentalValue test_value("string_value"); |
Joao da Silva
2011/11/07 13:06:17
Did you mean a StringValue here?
Mattias Nissler (ping if slow)
2011/11/09 14:37:27
Of course I did. Good catch! Pointers shouldn't be
| |
199 dict.Set(GetParam().policy_key(), GetParam().test_value()->DeepCopy()); | 138 CheckValue("StringPolicy", kPolicyHomepageLocation, test_value); |
200 WriteConfigFile(dict, "policy"); | |
201 ConfigDirPolicyProvider provider(GetChromePolicyDefinitionList(), test_dir()); | |
202 PolicyMap policy_map; | |
203 EXPECT_TRUE(provider.Provide(&policy_map)); | |
204 EXPECT_EQ(1U, policy_map.size()); | |
205 const Value* value = policy_map.Get(GetParam().type()); | |
206 ASSERT_TRUE(value); | |
207 EXPECT_TRUE(GetParam().test_value()->Equals(value)); | |
208 } | 139 } |
209 | 140 |
210 // Test parameters for all supported policies. testing::Values() has a limit of | 141 TEST_F(ConfigDirPolicyProviderTest, TestBooleanPolicy) { |
211 // 50 parameters which is reached in this instantiation; new policies should go | 142 base::FundamentalValue test_value(true); |
212 // in a new instantiation. | 143 CheckValue("BooleanPolicy", kPolicyHomepageIsNewTabPage, test_value); |
213 INSTANTIATE_TEST_CASE_P( | 144 } |
214 ConfigDirPolicyProviderValueTestInstance, | |
215 ConfigDirPolicyProviderValueTest, | |
216 testing::Values( | |
217 ValueTestParams::ForStringPolicy( | |
218 kPolicyHomepageLocation, | |
219 key::kHomepageLocation), | |
220 ValueTestParams::ForBooleanPolicy( | |
221 kPolicyHomepageIsNewTabPage, | |
222 key::kHomepageIsNewTabPage), | |
223 ValueTestParams::ForIntegerPolicy( | |
224 kPolicyRestoreOnStartup, | |
225 key::kRestoreOnStartup), | |
226 ValueTestParams::ForListPolicy( | |
227 kPolicyRestoreOnStartupURLs, | |
228 key::kRestoreOnStartupURLs), | |
229 ValueTestParams::ForBooleanPolicy( | |
230 kPolicyDefaultSearchProviderEnabled, | |
231 key::kDefaultSearchProviderEnabled), | |
232 ValueTestParams::ForStringPolicy( | |
233 kPolicyDefaultSearchProviderName, | |
234 key::kDefaultSearchProviderName), | |
235 ValueTestParams::ForStringPolicy( | |
236 kPolicyDefaultSearchProviderKeyword, | |
237 key::kDefaultSearchProviderKeyword), | |
238 ValueTestParams::ForStringPolicy( | |
239 kPolicyDefaultSearchProviderSearchURL, | |
240 key::kDefaultSearchProviderSearchURL), | |
241 ValueTestParams::ForStringPolicy( | |
242 kPolicyDefaultSearchProviderSuggestURL, | |
243 key::kDefaultSearchProviderSuggestURL), | |
244 ValueTestParams::ForStringPolicy( | |
245 kPolicyDefaultSearchProviderInstantURL, | |
246 key::kDefaultSearchProviderInstantURL), | |
247 ValueTestParams::ForStringPolicy( | |
248 kPolicyDefaultSearchProviderIconURL, | |
249 key::kDefaultSearchProviderIconURL), | |
250 ValueTestParams::ForListPolicy( | |
251 kPolicyDefaultSearchProviderEncodings, | |
252 key::kDefaultSearchProviderEncodings), | |
253 ValueTestParams::ForStringPolicy( | |
254 kPolicyProxyMode, | |
255 key::kProxyMode), | |
256 ValueTestParams::ForIntegerPolicy( | |
257 kPolicyProxyServerMode, | |
258 key::kProxyServerMode), | |
259 ValueTestParams::ForStringPolicy( | |
260 kPolicyProxyServer, | |
261 key::kProxyServer), | |
262 ValueTestParams::ForStringPolicy( | |
263 kPolicyProxyPacUrl, | |
264 key::kProxyPacUrl), | |
265 ValueTestParams::ForStringPolicy( | |
266 kPolicyProxyBypassList, | |
267 key::kProxyBypassList), | |
268 ValueTestParams::ForBooleanPolicy( | |
269 kPolicyAlternateErrorPagesEnabled, | |
270 key::kAlternateErrorPagesEnabled), | |
271 ValueTestParams::ForBooleanPolicy( | |
272 kPolicySearchSuggestEnabled, | |
273 key::kSearchSuggestEnabled), | |
274 ValueTestParams::ForBooleanPolicy( | |
275 kPolicyDnsPrefetchingEnabled, | |
276 key::kDnsPrefetchingEnabled), | |
277 ValueTestParams::ForBooleanPolicy( | |
278 kPolicySafeBrowsingEnabled, | |
279 key::kSafeBrowsingEnabled), | |
280 ValueTestParams::ForBooleanPolicy( | |
281 kPolicyMetricsReportingEnabled, | |
282 key::kMetricsReportingEnabled), | |
283 ValueTestParams::ForBooleanPolicy( | |
284 kPolicyPasswordManagerEnabled, | |
285 key::kPasswordManagerEnabled), | |
286 ValueTestParams::ForBooleanPolicy( | |
287 kPolicyPasswordManagerAllowShowPasswords, | |
288 key::kPasswordManagerAllowShowPasswords), | |
289 ValueTestParams::ForListPolicy( | |
290 kPolicyDisabledPlugins, | |
291 key::kDisabledPlugins), | |
292 ValueTestParams::ForListPolicy( | |
293 kPolicyDisabledPluginsExceptions, | |
294 key::kDisabledPluginsExceptions), | |
295 ValueTestParams::ForListPolicy( | |
296 kPolicyEnabledPlugins, | |
297 key::kEnabledPlugins), | |
298 ValueTestParams::ForBooleanPolicy( | |
299 kPolicyAutoFillEnabled, | |
300 key::kAutoFillEnabled), | |
301 ValueTestParams::ForStringPolicy( | |
302 kPolicyApplicationLocaleValue, | |
303 key::kApplicationLocaleValue), | |
304 ValueTestParams::ForBooleanPolicy( | |
305 kPolicySyncDisabled, | |
306 key::kSyncDisabled), | |
307 ValueTestParams::ForListPolicy( | |
308 kPolicyExtensionInstallWhitelist, | |
309 key::kExtensionInstallWhitelist), | |
310 ValueTestParams::ForListPolicy( | |
311 kPolicyExtensionInstallBlacklist, | |
312 key::kExtensionInstallBlacklist), | |
313 ValueTestParams::ForBooleanPolicy( | |
314 kPolicyShowHomeButton, | |
315 key::kShowHomeButton), | |
316 ValueTestParams::ForBooleanPolicy( | |
317 kPolicyPrintingEnabled, | |
318 key::kPrintingEnabled), | |
319 ValueTestParams::ForBooleanPolicy( | |
320 kPolicyInstantEnabled, | |
321 key::kInstantEnabled), | |
322 ValueTestParams::ForIntegerPolicy( | |
323 kPolicyIncognitoModeAvailability, | |
324 key::kIncognitoModeAvailability), | |
325 ValueTestParams::ForBooleanPolicy( | |
326 kPolicyDisablePluginFinder, | |
327 key::kDisablePluginFinder), | |
328 ValueTestParams::ForBooleanPolicy( | |
329 kPolicyClearSiteDataOnExit, | |
330 key::kClearSiteDataOnExit), | |
331 ValueTestParams::ForStringPolicy( | |
332 kPolicyDownloadDirectory, | |
333 key::kDownloadDirectory), | |
334 ValueTestParams::ForBooleanPolicy( | |
335 kPolicyDefaultBrowserSettingEnabled, | |
336 key::kDefaultBrowserSettingEnabled), | |
337 ValueTestParams::ForBooleanPolicy( | |
338 kPolicyCloudPrintProxyEnabled, | |
339 key::kCloudPrintProxyEnabled), | |
340 ValueTestParams::ForBooleanPolicy( | |
341 kPolicyTranslateEnabled, | |
342 key::kTranslateEnabled), | |
343 ValueTestParams::ForBooleanPolicy( | |
344 kPolicyAllowOutdatedPlugins, | |
345 key::kAllowOutdatedPlugins), | |
346 ValueTestParams::ForBooleanPolicy( | |
347 kPolicyAlwaysAuthorizePlugins, | |
348 key::kAlwaysAuthorizePlugins), | |
349 ValueTestParams::ForBooleanPolicy( | |
350 kPolicyBookmarkBarEnabled, | |
351 key::kBookmarkBarEnabled), | |
352 ValueTestParams::ForBooleanPolicy( | |
353 kPolicyEditBookmarksEnabled, | |
354 key::kEditBookmarksEnabled), | |
355 ValueTestParams::ForListPolicy( | |
356 kPolicyDisabledSchemes, | |
357 key::kDisabledSchemes), | |
358 ValueTestParams::ForStringPolicy( | |
359 kPolicyDiskCacheDir, | |
360 key::kDiskCacheDir), | |
361 ValueTestParams::ForListPolicy( | |
362 kPolicyURLBlacklist, | |
363 key::kURLBlacklist), | |
364 ValueTestParams::ForListPolicy( | |
365 kPolicyURLWhitelist, | |
366 key::kURLWhitelist))); | |
367 | 145 |
368 // Adds additional cases that can't be included in | 146 TEST_F(ConfigDirPolicyProviderTest, TestIntegerPolicy) { |
369 // ConfigDirPolicyProviderValueTestInstance since testing::Values is limited | 147 base::FundamentalValue test_value(42); |
370 // to 50 entries. | 148 CheckValue("IntegerPolicy", kPolicyRestoreOnStartup, test_value); |
371 INSTANTIATE_TEST_CASE_P( | 149 } |
372 ConfigDirPolicyProviderValueTestInstanceContinued, | |
373 ConfigDirPolicyProviderValueTest, | |
374 testing::Values( | |
375 ValueTestParams::ForBooleanPolicy( | |
376 kPolicyCloudPrintSubmitEnabled, | |
377 key::kCloudPrintSubmitEnabled))); | |
378 | 150 |
379 // Test parameters for all policies that are supported on ChromeOS only. | 151 TEST_F(ConfigDirPolicyProviderTest, TestStringListPolicy) { |
380 #if defined(OS_CHROMEOS) | 152 base::ListValue test_value; |
381 INSTANTIATE_TEST_CASE_P( | 153 test_value.Set(0U, base::Value::CreateStringValue("first")); |
382 ConfigDirPolicyProviderValueTestChromeOSInstance, | 154 test_value.Set(1U, base::Value::CreateStringValue("second")); |
383 ConfigDirPolicyProviderValueTest, | 155 CheckValue("StringListPolicy", kPolicyRestoreOnStartupURLs, test_value); |
384 testing::Values( | 156 } |
385 ValueTestParams::ForIntegerPolicy( | |
386 kPolicyPolicyRefreshRate, | |
387 key::kPolicyRefreshRate))); | |
388 #endif | |
389 | 157 |
390 } // namespace policy | 158 } // namespace policy |
OLD | NEW |