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

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

Issue 2257793002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 months 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::WrapUnique(new base::FundamentalValue(true)), nullptr); 91 base::MakeUnique<base::FundamentalValue>(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::WrapUnique(new 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::WrapUnique(new 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::WrapUnique(new 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,
102 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 102 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
103 base::WrapUnique(new base::StringValue(kSuggestURL)), nullptr); 103 base::MakeUnique<base::StringValue>(kSuggestURL), nullptr);
104 policy->Set(key::kDefaultSearchProviderIconURL, POLICY_LEVEL_MANDATORY, 104 policy->Set(key::kDefaultSearchProviderIconURL, POLICY_LEVEL_MANDATORY,
105 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 105 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
106 base::WrapUnique(new base::StringValue(kIconURL)), nullptr); 106 base::MakeUnique<base::StringValue>(kIconURL), nullptr);
107 policy->Set(key::kDefaultSearchProviderEncodings, POLICY_LEVEL_MANDATORY, 107 policy->Set(key::kDefaultSearchProviderEncodings, POLICY_LEVEL_MANDATORY,
108 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 108 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
109 base::WrapUnique(encodings), nullptr); 109 base::WrapUnique(encodings), nullptr);
110 policy->Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, 110 policy->Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY,
111 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 111 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
112 default_alternate_urls_.CreateDeepCopy(), nullptr); 112 default_alternate_urls_.CreateDeepCopy(), nullptr);
113 policy->Set(key::kDefaultSearchProviderSearchTermsReplacementKey, 113 policy->Set(key::kDefaultSearchProviderSearchTermsReplacementKey,
114 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 114 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
115 base::WrapUnique(new base::StringValue(kReplacementKey)), 115 base::MakeUnique<base::StringValue>(kReplacementKey), nullptr);
116 nullptr);
117 policy->Set(key::kDefaultSearchProviderImageURL, POLICY_LEVEL_MANDATORY, 116 policy->Set(key::kDefaultSearchProviderImageURL, POLICY_LEVEL_MANDATORY,
118 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 117 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
119 base::WrapUnique(new base::StringValue(kImageURL)), nullptr); 118 base::MakeUnique<base::StringValue>(kImageURL), nullptr);
120 policy->Set(key::kDefaultSearchProviderImageURLPostParams, 119 policy->Set(key::kDefaultSearchProviderImageURLPostParams,
121 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 120 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
122 base::WrapUnique(new base::StringValue(kImageParams)), nullptr); 121 base::MakeUnique<base::StringValue>(kImageParams), nullptr);
123 policy->Set(key::kDefaultSearchProviderNewTabURL, POLICY_LEVEL_MANDATORY, 122 policy->Set(key::kDefaultSearchProviderNewTabURL, POLICY_LEVEL_MANDATORY,
124 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 123 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
125 base::WrapUnique(new base::StringValue(kNewTabURL)), nullptr); 124 base::MakeUnique<base::StringValue>(kNewTabURL), nullptr);
126 } 125 }
127 126
128 // Checks that if the default search policy is missing, that no elements of the 127 // Checks that if the default search policy is missing, that no elements of the
129 // default search policy will be present. 128 // default search policy will be present.
130 TEST_F(DefaultSearchPolicyHandlerTest, MissingUrl) { 129 TEST_F(DefaultSearchPolicyHandlerTest, MissingUrl) {
131 PolicyMap policy; 130 PolicyMap policy;
132 BuildDefaultSearchPolicy(&policy); 131 BuildDefaultSearchPolicy(&policy);
133 policy.Erase(key::kDefaultSearchProviderSearchURL); 132 policy.Erase(key::kDefaultSearchProviderSearchURL);
134 UpdateProviderPolicy(policy); 133 UpdateProviderPolicy(policy);
135 134
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 temp->GetAsDictionary(&dictionary); 310 temp->GetAsDictionary(&dictionary);
312 311
313 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kURL, &value)); 312 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kURL, &value));
314 EXPECT_EQ(kFileSearchURL, value); 313 EXPECT_EQ(kFileSearchURL, value);
315 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kShortName, &value)); 314 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kShortName, &value));
316 EXPECT_EQ("_", value); 315 EXPECT_EQ("_", value);
317 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kKeyword, &value)); 316 EXPECT_TRUE(dictionary->GetString(DefaultSearchManager::kKeyword, &value));
318 EXPECT_EQ("_", value); 317 EXPECT_EQ("_", value);
319 } 318 }
320 } // namespace policy 319 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698