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

Side by Side Diff: chrome/browser/ui/webui/policy_ui_browsertest.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <vector> 5 #include <vector>
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/policy/browser_policy_connector.h" 10 #include "chrome/browser/policy/browser_policy_connector.h"
(...skipping 25 matching lines...) Expand all
36 const policy::PolicyMap::Entry* metadata, 36 const policy::PolicyMap::Entry* metadata,
37 bool unknown) { 37 bool unknown) {
38 std::vector<std::string> expected_policy; 38 std::vector<std::string> expected_policy;
39 39
40 // Populate expected scope. 40 // Populate expected scope.
41 if (metadata) { 41 if (metadata) {
42 expected_policy.push_back(l10n_util::GetStringUTF8( 42 expected_policy.push_back(l10n_util::GetStringUTF8(
43 metadata->scope == policy::POLICY_SCOPE_MACHINE ? 43 metadata->scope == policy::POLICY_SCOPE_MACHINE ?
44 IDS_POLICY_SCOPE_DEVICE : IDS_POLICY_SCOPE_USER)); 44 IDS_POLICY_SCOPE_DEVICE : IDS_POLICY_SCOPE_USER));
45 } else { 45 } else {
46 expected_policy.push_back(""); 46 expected_policy.push_back(std::string());
47 } 47 }
48 48
49 // Populate expected level. 49 // Populate expected level.
50 if (metadata) { 50 if (metadata) {
51 expected_policy.push_back(l10n_util::GetStringUTF8( 51 expected_policy.push_back(l10n_util::GetStringUTF8(
52 metadata->level == policy::POLICY_LEVEL_RECOMMENDED ? 52 metadata->level == policy::POLICY_LEVEL_RECOMMENDED ?
53 IDS_POLICY_LEVEL_RECOMMENDED : IDS_POLICY_LEVEL_MANDATORY)); 53 IDS_POLICY_LEVEL_RECOMMENDED : IDS_POLICY_LEVEL_MANDATORY));
54 } else { 54 } else {
55 expected_policy.push_back(""); 55 expected_policy.push_back(std::string());
56 } 56 }
57 57
58 // Populate expected policy name. 58 // Populate expected policy name.
59 expected_policy.push_back(name); 59 expected_policy.push_back(name);
60 60
61 // Populate expected policy value. 61 // Populate expected policy value.
62 expected_policy.push_back(value); 62 expected_policy.push_back(value);
63 63
64 // Populate expected status. 64 // Populate expected status.
65 if (unknown) 65 if (unknown)
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // the correct order. 171 // the correct order.
172 172
173 // Expect that the policy table contains all known policies in alphabetical 173 // Expect that the policy table contains all known policies in alphabetical
174 // order and none of the policies have a set value. 174 // order and none of the policies have a set value.
175 std::vector<std::vector<std::string> > expected_policies; 175 std::vector<std::vector<std::string> > expected_policies;
176 const policy::PolicyDefinitionList* policies = 176 const policy::PolicyDefinitionList* policies =
177 policy::GetChromePolicyDefinitionList(); 177 policy::GetChromePolicyDefinitionList();
178 for (const policy::PolicyDefinitionList::Entry* policy = policies->begin; 178 for (const policy::PolicyDefinitionList::Entry* policy = policies->begin;
179 policy != policies->end; ++policy) { 179 policy != policies->end; ++policy) {
180 expected_policies.push_back( 180 expected_policies.push_back(
181 PopulateExpectedPolicy(policy->name, "", NULL, false)); 181 PopulateExpectedPolicy(policy->name, std::string(), NULL, false));
182 } 182 }
183 183
184 // Retrieve the contents of the policy table from the UI and verify that it 184 // Retrieve the contents of the policy table from the UI and verify that it
185 // matches the expectation. 185 // matches the expectation.
186 VerifyPolicies(expected_policies); 186 VerifyPolicies(expected_policies);
187 } 187 }
188 188
189 IN_PROC_BROWSER_TEST_F(PolicyUITest, SendPolicyValues) { 189 IN_PROC_BROWSER_TEST_F(PolicyUITest, SendPolicyValues) {
190 // Verifies that policy values are sent to the UI and processed there 190 // Verifies that policy values are sent to the UI and processed there
191 // correctly by setting the values of four known and one unknown policy and 191 // correctly by setting the values of four known and one unknown policy and
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // * The unknown policy. 233 // * The unknown policy.
234 // * All known policies whose value has not been set, in alphabetical order. 234 // * All known policies whose value has not been set, in alphabetical order.
235 std::vector<std::vector<std::string> > expected_policies; 235 std::vector<std::vector<std::string> > expected_policies;
236 size_t first_unset_position = 0; 236 size_t first_unset_position = 0;
237 const policy::PolicyDefinitionList* policies = 237 const policy::PolicyDefinitionList* policies =
238 policy::GetChromePolicyDefinitionList(); 238 policy::GetChromePolicyDefinitionList();
239 for (const policy::PolicyDefinitionList::Entry* policy = policies->begin; 239 for (const policy::PolicyDefinitionList::Entry* policy = policies->begin;
240 policy != policies->end; ++policy) { 240 policy != policies->end; ++policy) {
241 std::map<std::string, std::string>::const_iterator it = 241 std::map<std::string, std::string>::const_iterator it =
242 expected_values.find(policy->name); 242 expected_values.find(policy->name);
243 const std::string value = it == expected_values.end() ? "" : it->second; 243 const std::string value =
244 it == expected_values.end() ? std::string() : it->second;
244 const policy::PolicyMap::Entry* metadata = values.Get(policy->name); 245 const policy::PolicyMap::Entry* metadata = values.Get(policy->name);
245 expected_policies.insert( 246 expected_policies.insert(
246 metadata ? expected_policies.begin() + first_unset_position++ : 247 metadata ? expected_policies.begin() + first_unset_position++ :
247 expected_policies.end(), 248 expected_policies.end(),
248 PopulateExpectedPolicy(policy->name, value, metadata, false)); 249 PopulateExpectedPolicy(policy->name, value, metadata, false));
249 } 250 }
250 expected_policies.insert( 251 expected_policies.insert(
251 expected_policies.begin() + first_unset_position++, 252 expected_policies.begin() + first_unset_position++,
252 PopulateExpectedPolicy(kUnknownPolicy, 253 PopulateExpectedPolicy(kUnknownPolicy,
253 expected_values[kUnknownPolicy], 254 expected_values[kUnknownPolicy],
254 values.Get(kUnknownPolicy), 255 values.Get(kUnknownPolicy),
255 true)); 256 true));
256 257
257 // Retrieve the contents of the policy table from the UI and verify that it 258 // Retrieve the contents of the policy table from the UI and verify that it
258 // matches the expectation. 259 // matches the expectation.
259 VerifyPolicies(expected_policies); 260 VerifyPolicies(expected_policies);
260 } 261 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698