Fixed MSAN uninitialized-value warning.
[chromium-blink-merge.git] / components / search_engines / default_search_policy_handler_unittest.cc
bloba79b5a6c798307cc974494b13d708f2a33925795
1 // Copyright 2014 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 #include "base/memory/scoped_ptr.h"
6 #include "components/policy/core/browser/configuration_policy_pref_store.h"
7 #include "components/policy/core/browser/configuration_policy_pref_store_test.h"
8 #include "components/search_engines/default_search_manager.h"
9 #include "components/search_engines/default_search_policy_handler.h"
10 #include "components/search_engines/search_engines_pref_names.h"
11 #include "policy/policy_constants.h"
13 namespace {
14 // TODO(caitkp): Should we find a way to route this through DefaultSearchManager
15 // to avoid hardcoding this here?
16 const char kDefaultSearchProviderData[] =
17 "default_search_provider_data.template_url_data";
18 } // namespace
20 namespace policy {
22 class DefaultSearchPolicyHandlerTest
23 : public ConfigurationPolicyPrefStoreTest {
24 public:
25 DefaultSearchPolicyHandlerTest() {
26 default_alternate_urls_.AppendString(
27 "http://www.google.com/#q={searchTerms}");
28 default_alternate_urls_.AppendString(
29 "http://www.google.com/search#q={searchTerms}");
32 virtual void SetUp() OVERRIDE {
33 handler_list_.AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
34 new DefaultSearchPolicyHandler));
37 protected:
38 static const char kSearchURL[];
39 static const char kSuggestURL[];
40 static const char kIconURL[];
41 static const char kName[];
42 static const char kKeyword[];
43 static const char kReplacementKey[];
44 static const char kImageURL[];
45 static const char kImageParams[];
46 static const char kNewTabURL[];
47 static const char kFileSearchURL[];
48 static const char kHostName[];
50 // Build a default search policy by setting search-related keys in |policy| to
51 // reasonable values. You can update any of the keys after calling this
52 // method.
53 void BuildDefaultSearchPolicy(PolicyMap* policy);
55 base::ListValue default_alternate_urls_;
58 const char DefaultSearchPolicyHandlerTest::kSearchURL[] =
59 "http://test.com/search?t={searchTerms}";
60 const char DefaultSearchPolicyHandlerTest::kSuggestURL[] =
61 "http://test.com/sugg?={searchTerms}";
62 const char DefaultSearchPolicyHandlerTest::kIconURL[] =
63 "http://test.com/icon.jpg";
64 const char DefaultSearchPolicyHandlerTest::kName[] =
65 "MyName";
66 const char DefaultSearchPolicyHandlerTest::kKeyword[] =
67 "MyKeyword";
68 const char DefaultSearchPolicyHandlerTest::kReplacementKey[] =
69 "espv";
70 const char DefaultSearchPolicyHandlerTest::kImageURL[] =
71 "http://test.com/searchbyimage/upload";
72 const char DefaultSearchPolicyHandlerTest::kImageParams[] =
73 "image_content=content,image_url=http://test.com/test.png";
74 const char DefaultSearchPolicyHandlerTest::kNewTabURL[] =
75 "http://test.com/newtab";
76 const char DefaultSearchPolicyHandlerTest::kFileSearchURL[] =
77 "file:///c:/path/to/search?t={searchTerms}";
78 const char DefaultSearchPolicyHandlerTest::kHostName[] = "test.com";
80 void DefaultSearchPolicyHandlerTest::
81 BuildDefaultSearchPolicy(PolicyMap* policy) {
82 base::ListValue* encodings = new base::ListValue();
83 encodings->AppendString("UTF-16");
84 encodings->AppendString("UTF-8");
85 policy->Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY,
86 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL);
87 policy->Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY,
88 POLICY_SCOPE_USER, base::Value::CreateStringValue(kSearchURL),
89 NULL);
90 policy->Set(key::kDefaultSearchProviderName, POLICY_LEVEL_MANDATORY,
91 POLICY_SCOPE_USER, base::Value::CreateStringValue(kName), NULL);
92 policy->Set(key::kDefaultSearchProviderKeyword, POLICY_LEVEL_MANDATORY,
93 POLICY_SCOPE_USER, base::Value::CreateStringValue(kKeyword),
94 NULL);
95 policy->Set(key::kDefaultSearchProviderSuggestURL, POLICY_LEVEL_MANDATORY,
96 POLICY_SCOPE_USER, base::Value::CreateStringValue(kSuggestURL),
97 NULL);
98 policy->Set(key::kDefaultSearchProviderIconURL, POLICY_LEVEL_MANDATORY,
99 POLICY_SCOPE_USER, base::Value::CreateStringValue(kIconURL),
100 NULL);
101 policy->Set(key::kDefaultSearchProviderEncodings, POLICY_LEVEL_MANDATORY,
102 POLICY_SCOPE_USER, encodings, NULL);
103 policy->Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY,
104 POLICY_SCOPE_USER, default_alternate_urls_.DeepCopy(), NULL);
105 policy->Set(key::kDefaultSearchProviderSearchTermsReplacementKey,
106 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
107 base::Value::CreateStringValue(kReplacementKey), NULL);
108 policy->Set(key::kDefaultSearchProviderImageURL,
109 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
110 base::Value::CreateStringValue(kImageURL), NULL);
111 policy->Set(key::kDefaultSearchProviderImageURLPostParams,
112 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
113 base::Value::CreateStringValue(kImageParams), NULL);
114 policy->Set(key::kDefaultSearchProviderNewTabURL,
115 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
116 base::Value::CreateStringValue(kNewTabURL), NULL);
119 // Checks that if the policy for default search is valid, i.e. there's a
120 // search URL, that all the elements have been given proper defaults.
121 TEST_F(DefaultSearchPolicyHandlerTest, MinimallyDefined) {
122 PolicyMap policy;
123 policy.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY,
124 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL);
125 policy.Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY,
126 POLICY_SCOPE_USER, base::Value::CreateStringValue(kSearchURL),
127 NULL);
128 UpdateProviderPolicy(policy);
130 const base::Value* value = NULL;
131 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderSearchURL, &value));
132 EXPECT_TRUE(base::StringValue(kSearchURL).Equals(value));
134 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderName, &value));
135 EXPECT_TRUE(base::StringValue(kHostName).Equals(value));
137 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderKeyword, &value));
138 EXPECT_TRUE(base::StringValue(kHostName).Equals(value));
140 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderSuggestURL,
141 &value));
142 EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
144 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderIconURL, &value));
145 EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
147 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderEncodings, &value));
148 EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
150 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderInstantURL,
151 &value));
152 EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
154 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderAlternateURLs,
155 &value));
156 EXPECT_TRUE(base::ListValue().Equals(value));
158 EXPECT_TRUE(
159 store_->GetValue(prefs::kDefaultSearchProviderSearchTermsReplacementKey,
160 &value));
161 EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
163 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderImageURL, &value));
164 EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
166 EXPECT_TRUE(store_->GetValue(
167 prefs::kDefaultSearchProviderSearchURLPostParams, &value));
168 EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
170 EXPECT_TRUE(store_->GetValue(
171 prefs::kDefaultSearchProviderSuggestURLPostParams, &value));
172 EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
174 EXPECT_TRUE(store_->GetValue(
175 prefs::kDefaultSearchProviderInstantURLPostParams, &value));
176 EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
178 EXPECT_TRUE(store_->GetValue(
179 prefs::kDefaultSearchProviderImageURLPostParams, &value));
180 EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
182 EXPECT_TRUE(store_->GetValue(
183 prefs::kDefaultSearchProviderNewTabURL, &value));
184 EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
187 // Checks that for a fully defined search policy, all elements have been
188 // read properly.
189 TEST_F(DefaultSearchPolicyHandlerTest, FullyDefined) {
190 PolicyMap policy;
191 BuildDefaultSearchPolicy(&policy);
192 UpdateProviderPolicy(policy);
194 const base::Value* value = NULL;
195 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderSearchURL, &value));
196 EXPECT_TRUE(base::StringValue(kSearchURL).Equals(value));
198 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderName, &value));
199 EXPECT_TRUE(base::StringValue(kName).Equals(value));
201 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderKeyword, &value));
202 EXPECT_TRUE(base::StringValue(kKeyword).Equals(value));
204 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderSuggestURL,
205 &value));
206 EXPECT_TRUE(base::StringValue(kSuggestURL).Equals(value));
208 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderIconURL, &value));
209 EXPECT_TRUE(base::StringValue(kIconURL).Equals(value));
211 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderEncodings, &value));
212 EXPECT_TRUE(base::StringValue("UTF-16;UTF-8").Equals(value));
214 EXPECT_TRUE(store_->GetValue(
215 prefs::kDefaultSearchProviderAlternateURLs, &value));
216 EXPECT_TRUE(default_alternate_urls_.Equals(value));
218 EXPECT_TRUE(
219 store_->GetValue(prefs::kDefaultSearchProviderSearchTermsReplacementKey,
220 &value));
221 EXPECT_TRUE(base::StringValue(kReplacementKey).Equals(value));
223 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderImageURL, &value));
224 EXPECT_TRUE(base::StringValue(std::string(kImageURL)).Equals(value));
226 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderImageURLPostParams,
227 &value));
228 EXPECT_TRUE(base::StringValue(std::string(kImageParams)).Equals(value));
230 EXPECT_TRUE(store_->GetValue(
231 prefs::kDefaultSearchProviderSearchURLPostParams, &value));
232 EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
234 EXPECT_TRUE(store_->GetValue(
235 prefs::kDefaultSearchProviderSuggestURLPostParams, &value));
236 EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
238 EXPECT_TRUE(store_->GetValue(
239 prefs::kDefaultSearchProviderInstantURLPostParams, &value));
240 EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
243 // Checks that if the default search policy is missing, that no elements of the
244 // default search policy will be present.
245 TEST_F(DefaultSearchPolicyHandlerTest, MissingUrl) {
246 PolicyMap policy;
247 BuildDefaultSearchPolicy(&policy);
248 policy.Erase(key::kDefaultSearchProviderSearchURL);
249 UpdateProviderPolicy(policy);
251 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderSearchURL, NULL));
252 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderName, NULL));
253 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderKeyword, NULL));
254 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderSuggestURL, NULL));
255 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderIconURL, NULL));
256 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderEncodings, NULL));
257 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderAlternateURLs,
258 NULL));
259 EXPECT_FALSE(store_->GetValue(
260 prefs::kDefaultSearchProviderSearchTermsReplacementKey, NULL));
261 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderImageURL, NULL));
262 EXPECT_FALSE(store_->GetValue(
263 prefs::kDefaultSearchProviderImageURLPostParams, NULL));
264 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderInstantURL, NULL));
265 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderNewTabURL, NULL));
268 // Checks that if the default search policy is invalid, that no elements of the
269 // default search policy will be present.
270 TEST_F(DefaultSearchPolicyHandlerTest, Invalid) {
271 PolicyMap policy;
272 BuildDefaultSearchPolicy(&policy);
273 const char bad_search_url[] = "http://test.com/noSearchTerms";
274 policy.Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY,
275 POLICY_SCOPE_USER,
276 base::Value::CreateStringValue(bad_search_url), NULL);
277 UpdateProviderPolicy(policy);
279 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderSearchURL, NULL));
280 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderName, NULL));
281 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderKeyword, NULL));
282 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderSuggestURL, NULL));
283 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderIconURL, NULL));
284 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderEncodings, NULL));
285 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderAlternateURLs,
286 NULL));
287 EXPECT_FALSE(store_->GetValue(
288 prefs::kDefaultSearchProviderSearchTermsReplacementKey, NULL));
289 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderImageURL, NULL));
290 EXPECT_FALSE(store_->GetValue(
291 prefs::kDefaultSearchProviderImageURLPostParams, NULL));
292 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderInstantURL, NULL));
293 EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderNewTabURL, NULL));
296 // Checks that if the default search policy is invalid, that no elements of the
297 // default search policy will be present.
298 TEST_F(DefaultSearchPolicyHandlerTest, Disabled) {
299 PolicyMap policy;
300 policy.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY,
301 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL);
302 UpdateProviderPolicy(policy);
304 const base::Value* value = NULL;
305 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderEnabled, &value));
306 base::FundamentalValue expected_enabled(false);
307 EXPECT_TRUE(base::Value::Equals(&expected_enabled, value));
308 EXPECT_TRUE(store_->GetValue(prefs::kDefaultSearchProviderSearchURL, &value));
309 base::StringValue expected_search_url((std::string()));
310 EXPECT_TRUE(base::Value::Equals(&expected_search_url, value));
313 // Checks that for a fully defined search policy, all elements have been
314 // read properly into the dictionary pref.
315 TEST_F(DefaultSearchPolicyHandlerTest, DictionaryPref) {
316 PolicyMap policy;
317 BuildDefaultSearchPolicy(&policy);
318 UpdateProviderPolicy(policy);
320 const base::Value* temp = NULL;
321 const base::DictionaryValue* dictionary;
322 std::string value;
323 const base::ListValue* list_value;
324 EXPECT_TRUE(store_->GetValue(kDefaultSearchProviderData, &temp));
325 temp->GetAsDictionary(&dictionary);
327 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kURL, &value));
328 EXPECT_EQ(kSearchURL, value);
329 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kShortName, &value));
330 EXPECT_EQ(kName, value);
331 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kKeyword, &value));
332 EXPECT_EQ(kKeyword, value);
334 EXPECT_TRUE(
335 dictionary->GetString(DefaultSearchManager::kSuggestionsURL, &value));
336 EXPECT_EQ(kSuggestURL, value);
337 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kFaviconURL, &value));
338 EXPECT_EQ(kIconURL, value);
340 base::ListValue encodings;
341 encodings.AppendString("UTF-16");
342 encodings.AppendString("UTF-8");
344 EXPECT_TRUE(
345 dictionary->GetList(DefaultSearchManager::kInputEncodings, &list_value));
346 EXPECT_TRUE(encodings.Equals(list_value));
348 EXPECT_TRUE(
349 dictionary->GetList(DefaultSearchManager::kAlternateURLs, &list_value));
350 EXPECT_TRUE(default_alternate_urls_.Equals(list_value));
352 EXPECT_TRUE(dictionary->GetString(
353 DefaultSearchManager::kSearchTermsReplacementKey, &value));
354 EXPECT_EQ(kReplacementKey, value);
356 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kImageURL, &value));
357 EXPECT_EQ(kImageURL, value);
359 EXPECT_TRUE(
360 dictionary->GetString(DefaultSearchManager::kImageURLPostParams, &value));
361 EXPECT_EQ(kImageParams, value);
363 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kSearchURLPostParams,
364 &value));
365 EXPECT_EQ(std::string(), value);
367 EXPECT_TRUE(dictionary->GetString(
368 DefaultSearchManager::kSuggestionsURLPostParams, &value));
369 EXPECT_EQ(std::string(), value);
371 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kInstantURLPostParams,
372 &value));
373 EXPECT_EQ(std::string(), value);
376 // Checks that disabling default search is properly reflected the dictionary
377 // pref.
378 TEST_F(DefaultSearchPolicyHandlerTest, DictionaryPrefDSEDisabled) {
379 PolicyMap policy;
380 policy.Set(key::kDefaultSearchProviderEnabled,
381 POLICY_LEVEL_MANDATORY,
382 POLICY_SCOPE_USER,
383 base::Value::CreateBooleanValue(false),
384 NULL);
385 UpdateProviderPolicy(policy);
386 const base::Value* temp = NULL;
387 const base::DictionaryValue* dictionary;
388 EXPECT_TRUE(store_->GetValue(kDefaultSearchProviderData, &temp));
389 temp->GetAsDictionary(&dictionary);
390 bool disabled = false;
391 EXPECT_TRUE(dictionary->GetBoolean(DefaultSearchManager::kDisabledByPolicy,
392 &disabled));
393 EXPECT_TRUE(disabled);
396 // Checks that if the policy for default search is valid, i.e. there's a
397 // search URL, that all the elements have been given proper defaults.
398 TEST_F(DefaultSearchPolicyHandlerTest, DictionaryPrefMinimallyDefined) {
399 PolicyMap policy;
400 policy.Set(key::kDefaultSearchProviderEnabled,
401 POLICY_LEVEL_MANDATORY,
402 POLICY_SCOPE_USER,
403 base::Value::CreateBooleanValue(true),
404 NULL);
405 policy.Set(key::kDefaultSearchProviderSearchURL,
406 POLICY_LEVEL_MANDATORY,
407 POLICY_SCOPE_USER,
408 base::Value::CreateStringValue(kSearchURL),
409 NULL);
410 UpdateProviderPolicy(policy);
412 const base::Value* temp = NULL;
413 const base::DictionaryValue* dictionary;
414 std::string value;
415 const base::ListValue* list_value;
416 EXPECT_TRUE(store_->GetValue(kDefaultSearchProviderData, &temp));
417 temp->GetAsDictionary(&dictionary);
419 // Name and keyword should be derived from host.
420 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kURL, &value));
421 EXPECT_EQ(kSearchURL, value);
422 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kShortName, &value));
423 EXPECT_EQ(kHostName, value);
424 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kKeyword, &value));
425 EXPECT_EQ(kHostName, value);
427 // Everything else should be set to the default value.
428 EXPECT_TRUE(
429 dictionary->GetString(DefaultSearchManager::kSuggestionsURL, &value));
430 EXPECT_EQ(std::string(), value);
431 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kFaviconURL, &value));
432 EXPECT_EQ(std::string(), value);
433 EXPECT_TRUE(
434 dictionary->GetList(DefaultSearchManager::kInputEncodings, &list_value));
435 EXPECT_TRUE(base::ListValue().Equals(list_value));
436 EXPECT_TRUE(
437 dictionary->GetList(DefaultSearchManager::kAlternateURLs, &list_value));
438 EXPECT_TRUE(base::ListValue().Equals(list_value));
439 EXPECT_TRUE(dictionary->GetString(
440 DefaultSearchManager::kSearchTermsReplacementKey, &value));
441 EXPECT_EQ(std::string(), value);
442 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kImageURL, &value));
443 EXPECT_EQ(std::string(), value);
444 EXPECT_TRUE(
445 dictionary->GetString(DefaultSearchManager::kImageURLPostParams, &value));
446 EXPECT_EQ(std::string(), value);
447 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kSearchURLPostParams,
448 &value));
449 EXPECT_EQ(std::string(), value);
450 EXPECT_TRUE(dictionary->GetString(
451 DefaultSearchManager::kSuggestionsURLPostParams, &value));
452 EXPECT_EQ(std::string(), value);
453 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kInstantURLPostParams,
454 &value));
455 EXPECT_EQ(std::string(), value);
458 // Checks that setting a file URL as the default search is reflected properly in
459 // the dictionary pref.
460 TEST_F(DefaultSearchPolicyHandlerTest, DictionaryPrefFileURL) {
461 PolicyMap policy;
462 policy.Set(key::kDefaultSearchProviderEnabled,
463 POLICY_LEVEL_MANDATORY,
464 POLICY_SCOPE_USER,
465 base::Value::CreateBooleanValue(true),
466 NULL);
467 policy.Set(key::kDefaultSearchProviderSearchURL,
468 POLICY_LEVEL_MANDATORY,
469 POLICY_SCOPE_USER,
470 base::Value::CreateStringValue(kFileSearchURL),
471 NULL);
472 UpdateProviderPolicy(policy);
474 const base::Value* temp = NULL;
475 const base::DictionaryValue* dictionary;
476 std::string value;
478 EXPECT_TRUE(store_->GetValue(kDefaultSearchProviderData, &temp));
479 temp->GetAsDictionary(&dictionary);
481 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kURL, &value));
482 EXPECT_EQ(kFileSearchURL, value);
483 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kShortName, &value));
484 EXPECT_EQ("_", value);
485 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kKeyword, &value));
486 EXPECT_EQ("_", value);
488 } // namespace policy