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

Side by Side Diff: components/search_engines/default_search_policy_handler_unittest.cc

Issue 2476493003: Remove FundamentalValue
Patch Set: Fix Created 4 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "components/search_engines/default_search_policy_handler.h" 5 #include "components/search_engines/default_search_policy_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "components/policy/core/browser/configuration_policy_pref_store.h" 10 #include "components/policy/core/browser/configuration_policy_pref_store.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 "file:///c:/path/to/search?t={searchTerms}"; 81 "file:///c:/path/to/search?t={searchTerms}";
82 const char DefaultSearchPolicyHandlerTest::kHostName[] = "test.com"; 82 const char DefaultSearchPolicyHandlerTest::kHostName[] = "test.com";
83 83
84 void DefaultSearchPolicyHandlerTest:: 84 void DefaultSearchPolicyHandlerTest::
85 BuildDefaultSearchPolicy(PolicyMap* policy) { 85 BuildDefaultSearchPolicy(PolicyMap* policy) {
86 base::ListValue* encodings = new base::ListValue(); 86 base::ListValue* encodings = new base::ListValue();
87 encodings->AppendString("UTF-16"); 87 encodings->AppendString("UTF-16");
88 encodings->AppendString("UTF-8"); 88 encodings->AppendString("UTF-8");
89 policy->Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, 89 policy->Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY,
90 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 90 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
91 base::MakeUnique<base::FundamentalValue>(true), nullptr); 91 base::MakeUnique<base::Value>(true), nullptr);
92 policy->Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY, 92 policy->Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY,
93 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 93 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
94 base::MakeUnique<base::StringValue>(kSearchURL), nullptr); 94 base::MakeUnique<base::StringValue>(kSearchURL), nullptr);
95 policy->Set(key::kDefaultSearchProviderName, POLICY_LEVEL_MANDATORY, 95 policy->Set(key::kDefaultSearchProviderName, POLICY_LEVEL_MANDATORY,
96 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 96 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
97 base::MakeUnique<base::StringValue>(kName), nullptr); 97 base::MakeUnique<base::StringValue>(kName), nullptr);
98 policy->Set(key::kDefaultSearchProviderKeyword, POLICY_LEVEL_MANDATORY, 98 policy->Set(key::kDefaultSearchProviderKeyword, POLICY_LEVEL_MANDATORY,
99 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 99 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
100 base::MakeUnique<base::StringValue>(kKeyword), nullptr); 100 base::MakeUnique<base::StringValue>(kKeyword), nullptr);
101 policy->Set(key::kDefaultSearchProviderSuggestURL, POLICY_LEVEL_MANDATORY, 101 policy->Set(key::kDefaultSearchProviderSuggestURL, POLICY_LEVEL_MANDATORY,
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 &value)); 213 &value));
214 EXPECT_EQ(std::string(), value); 214 EXPECT_EQ(std::string(), value);
215 } 215 }
216 216
217 // Checks that disabling default search is properly reflected the dictionary 217 // Checks that disabling default search is properly reflected the dictionary
218 // pref. 218 // pref.
219 TEST_F(DefaultSearchPolicyHandlerTest, Disabled) { 219 TEST_F(DefaultSearchPolicyHandlerTest, Disabled) {
220 PolicyMap policy; 220 PolicyMap policy;
221 policy.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, 221 policy.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY,
222 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 222 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
223 base::WrapUnique(new base::FundamentalValue(false)), nullptr); 223 base::WrapUnique(new base::Value(false)), nullptr);
224 UpdateProviderPolicy(policy); 224 UpdateProviderPolicy(policy);
225 const base::Value* temp = NULL; 225 const base::Value* temp = NULL;
226 const base::DictionaryValue* dictionary; 226 const base::DictionaryValue* dictionary;
227 EXPECT_TRUE(store_->GetValue(kDefaultSearchProviderData, &temp)); 227 EXPECT_TRUE(store_->GetValue(kDefaultSearchProviderData, &temp));
228 temp->GetAsDictionary(&dictionary); 228 temp->GetAsDictionary(&dictionary);
229 bool disabled = false; 229 bool disabled = false;
230 EXPECT_TRUE(dictionary->GetBoolean(DefaultSearchManager::kDisabledByPolicy, 230 EXPECT_TRUE(dictionary->GetBoolean(DefaultSearchManager::kDisabledByPolicy,
231 &disabled)); 231 &disabled));
232 EXPECT_TRUE(disabled); 232 EXPECT_TRUE(disabled);
233 } 233 }
234 234
235 // Checks that if the policy for default search is valid, i.e. there's a 235 // Checks that if the policy for default search is valid, i.e. there's a
236 // search URL, that all the elements have been given proper defaults. 236 // search URL, that all the elements have been given proper defaults.
237 TEST_F(DefaultSearchPolicyHandlerTest, MinimallyDefined) { 237 TEST_F(DefaultSearchPolicyHandlerTest, MinimallyDefined) {
238 PolicyMap policy; 238 PolicyMap policy;
239 policy.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, 239 policy.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY,
240 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 240 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
241 base::WrapUnique(new base::FundamentalValue(true)), nullptr); 241 base::WrapUnique(new base::Value(true)), nullptr);
242 policy.Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY, 242 policy.Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY,
243 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 243 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
244 base::WrapUnique(new base::StringValue(kSearchURL)), nullptr); 244 base::WrapUnique(new base::StringValue(kSearchURL)), nullptr);
245 UpdateProviderPolicy(policy); 245 UpdateProviderPolicy(policy);
246 246
247 const base::Value* temp = NULL; 247 const base::Value* temp = NULL;
248 const base::DictionaryValue* dictionary; 248 const base::DictionaryValue* dictionary;
249 std::string value; 249 std::string value;
250 const base::ListValue* list_value; 250 const base::ListValue* list_value;
251 EXPECT_TRUE(store_->GetValue(kDefaultSearchProviderData, &temp)); 251 EXPECT_TRUE(store_->GetValue(kDefaultSearchProviderData, &temp));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 &value)); 289 &value));
290 EXPECT_EQ(std::string(), value); 290 EXPECT_EQ(std::string(), value);
291 } 291 }
292 292
293 // Checks that setting a file URL as the default search is reflected properly in 293 // Checks that setting a file URL as the default search is reflected properly in
294 // the dictionary pref. 294 // the dictionary pref.
295 TEST_F(DefaultSearchPolicyHandlerTest, FileURL) { 295 TEST_F(DefaultSearchPolicyHandlerTest, FileURL) {
296 PolicyMap policy; 296 PolicyMap policy;
297 policy.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, 297 policy.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY,
298 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 298 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
299 base::WrapUnique(new base::FundamentalValue(true)), nullptr); 299 base::WrapUnique(new base::Value(true)), nullptr);
300 policy.Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY, 300 policy.Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY,
301 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 301 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
302 base::WrapUnique(new base::StringValue(kFileSearchURL)), nullptr); 302 base::WrapUnique(new base::StringValue(kFileSearchURL)), nullptr);
303 UpdateProviderPolicy(policy); 303 UpdateProviderPolicy(policy);
304 304
305 const base::Value* temp = NULL; 305 const base::Value* temp = NULL;
306 const base::DictionaryValue* dictionary; 306 const base::DictionaryValue* dictionary;
307 std::string value; 307 std::string value;
308 308
309 EXPECT_TRUE(store_->GetValue(kDefaultSearchProviderData, &temp)); 309 EXPECT_TRUE(store_->GetValue(kDefaultSearchProviderData, &temp));
310 temp->GetAsDictionary(&dictionary); 310 temp->GetAsDictionary(&dictionary);
311 311
312 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kURL, &value)); 312 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kURL, &value));
313 EXPECT_EQ(kFileSearchURL, value); 313 EXPECT_EQ(kFileSearchURL, value);
314 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kShortName, &value)); 314 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kShortName, &value));
315 EXPECT_EQ("_", value); 315 EXPECT_EQ("_", value);
316 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kKeyword, &value)); 316 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kKeyword, &value));
317 EXPECT_EQ("_", value); 317 EXPECT_EQ("_", value);
318 } 318 }
319 } // namespace policy 319 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698