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

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

Issue 58313002: Removed the PolicyDefinitionList. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome-policy-schema-10-use-registry
Patch Set: rebase Created 7 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/webui/policy_ui.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/callback.h" 7 #include "base/callback.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/policy/browser_policy_connector.h" 11 #include "chrome/browser/policy/browser_policy_connector.h"
12 #include "chrome/browser/policy/external_data_fetcher.h" 12 #include "chrome/browser/policy/external_data_fetcher.h"
13 #include "chrome/browser/policy/mock_configuration_policy_provider.h" 13 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
14 #include "chrome/browser/policy/policy_map.h" 14 #include "chrome/browser/policy/policy_map.h"
15 #include "chrome/browser/policy/policy_types.h" 15 #include "chrome/browser/policy/policy_types.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
19 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
20 #include "components/policy/core/common/schema.h"
20 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
21 #include "content/public/test/browser_test_utils.h" 22 #include "content/public/test/browser_test_utils.h"
22 #include "grit/generated_resources.h" 23 #include "grit/generated_resources.h"
23 #include "policy/policy_constants.h" 24 #include "policy/policy_constants.h"
24 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
25 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
26 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
27 #include "url/gurl.h" 28 #include "url/gurl.h"
28 29
29 using testing::Return; 30 using testing::Return;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 167 }
167 168
168 IN_PROC_BROWSER_TEST_F(PolicyUITest, SendPolicyNames) { 169 IN_PROC_BROWSER_TEST_F(PolicyUITest, SendPolicyNames) {
169 // Verifies that the names of known policies are sent to the UI and processed 170 // Verifies that the names of known policies are sent to the UI and processed
170 // there correctly by checking that the policy table contains all policies in 171 // there correctly by checking that the policy table contains all policies in
171 // the correct order. 172 // the correct order.
172 173
173 // Expect that the policy table contains all known policies in alphabetical 174 // Expect that the policy table contains all known policies in alphabetical
174 // order and none of the policies have a set value. 175 // order and none of the policies have a set value.
175 std::vector<std::vector<std::string> > expected_policies; 176 std::vector<std::vector<std::string> > expected_policies;
176 const policy::PolicyDefinitionList* policies = 177 policy::Schema chrome_schema =
177 policy::GetChromePolicyDefinitionList(); 178 policy::Schema::Wrap(policy::GetChromeSchemaData());
178 for (const policy::PolicyDefinitionList::Entry* policy = policies->begin; 179 ASSERT_TRUE(chrome_schema.valid());
179 policy != policies->end; ++policy) { 180 for (policy::Schema::Iterator it = chrome_schema.GetPropertiesIterator();
181 !it.IsAtEnd(); it.Advance()) {
180 expected_policies.push_back( 182 expected_policies.push_back(
181 PopulateExpectedPolicy(policy->name, std::string(), NULL, false)); 183 PopulateExpectedPolicy(it.key(), std::string(), NULL, false));
182 } 184 }
183 185
184 // Retrieve the contents of the policy table from the UI and verify that it 186 // Retrieve the contents of the policy table from the UI and verify that it
185 // matches the expectation. 187 // matches the expectation.
186 VerifyPolicies(expected_policies); 188 VerifyPolicies(expected_policies);
187 } 189 }
188 190
189 IN_PROC_BROWSER_TEST_F(PolicyUITest, SendPolicyValues) { 191 IN_PROC_BROWSER_TEST_F(PolicyUITest, SendPolicyValues) {
190 // Verifies that policy values are sent to the UI and processed there 192 // 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 193 // correctly by setting the values of four known and one unknown policy and
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 NULL); 234 NULL);
233 expected_values[kUnknownPolicy] = "true"; 235 expected_values[kUnknownPolicy] = "true";
234 UpdateProviderPolicy(values); 236 UpdateProviderPolicy(values);
235 237
236 // Expect that the policy table contains, in order: 238 // Expect that the policy table contains, in order:
237 // * All known policies whose value has been set, in alphabetical order. 239 // * All known policies whose value has been set, in alphabetical order.
238 // * The unknown policy. 240 // * The unknown policy.
239 // * All known policies whose value has not been set, in alphabetical order. 241 // * All known policies whose value has not been set, in alphabetical order.
240 std::vector<std::vector<std::string> > expected_policies; 242 std::vector<std::vector<std::string> > expected_policies;
241 size_t first_unset_position = 0; 243 size_t first_unset_position = 0;
242 const policy::PolicyDefinitionList* policies = 244 policy::Schema chrome_schema =
243 policy::GetChromePolicyDefinitionList(); 245 policy::Schema::Wrap(policy::GetChromeSchemaData());
244 for (const policy::PolicyDefinitionList::Entry* policy = policies->begin; 246 ASSERT_TRUE(chrome_schema.valid());
245 policy != policies->end; ++policy) { 247 for (policy::Schema::Iterator props = chrome_schema.GetPropertiesIterator();
248 !props.IsAtEnd(); props.Advance()) {
246 std::map<std::string, std::string>::const_iterator it = 249 std::map<std::string, std::string>::const_iterator it =
247 expected_values.find(policy->name); 250 expected_values.find(props.key());
248 const std::string value = 251 const std::string value =
249 it == expected_values.end() ? std::string() : it->second; 252 it == expected_values.end() ? std::string() : it->second;
250 const policy::PolicyMap::Entry* metadata = values.Get(policy->name); 253 const policy::PolicyMap::Entry* metadata = values.Get(props.key());
251 expected_policies.insert( 254 expected_policies.insert(
252 metadata ? expected_policies.begin() + first_unset_position++ : 255 metadata ? expected_policies.begin() + first_unset_position++ :
253 expected_policies.end(), 256 expected_policies.end(),
254 PopulateExpectedPolicy(policy->name, value, metadata, false)); 257 PopulateExpectedPolicy(props.key(), value, metadata, false));
255 } 258 }
256 expected_policies.insert( 259 expected_policies.insert(
257 expected_policies.begin() + first_unset_position++, 260 expected_policies.begin() + first_unset_position++,
258 PopulateExpectedPolicy(kUnknownPolicy, 261 PopulateExpectedPolicy(kUnknownPolicy,
259 expected_values[kUnknownPolicy], 262 expected_values[kUnknownPolicy],
260 values.Get(kUnknownPolicy), 263 values.Get(kUnknownPolicy),
261 true)); 264 true));
262 265
263 // Retrieve the contents of the policy table from the UI and verify that it 266 // Retrieve the contents of the policy table from the UI and verify that it
264 // matches the expectation. 267 // matches the expectation.
265 VerifyPolicies(expected_policies); 268 VerifyPolicies(expected_policies);
266 } 269 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/policy_ui.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698