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

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

Issue 1321713004: Flag for Material Design policy construction page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved policy page to independent page. Created 5 years, 2 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 (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/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 122
123 void PolicyUITest::UpdateProviderPolicy(const policy::PolicyMap& policy) { 123 void PolicyUITest::UpdateProviderPolicy(const policy::PolicyMap& policy) {
124 provider_.UpdateChromePolicy(policy); 124 provider_.UpdateChromePolicy(policy);
125 base::RunLoop loop; 125 base::RunLoop loop;
126 loop.RunUntilIdle(); 126 loop.RunUntilIdle();
127 } 127 }
128 128
129 void PolicyUITest::VerifyPolicies( 129 void PolicyUITest::VerifyPolicies(
130 const std::vector<std::vector<std::string> >& expected_policies) { 130 const std::vector<std::vector<std::string> >& expected_policies) {
131 ui_test_utils::NavigateToURL(browser(), GURL("chrome://policy")); 131 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIPolicyURL));
132 132
133 // Retrieve the text contents of the policy table cells for all policies. 133 // Retrieve the text contents of the policy table cells for all policies.
134 const std::string javascript = 134 const std::string javascript =
135 "var entries = document.querySelectorAll(" 135 "var entries = document.querySelectorAll("
136 " 'section.policy-table-section > * > tbody');" 136 " 'section.policy-table-section > * > tbody');"
137 "var policies = [];" 137 "var policies = [];"
138 "for (var i = 0; i < entries.length; ++i) {" 138 "for (var i = 0; i < entries.length; ++i) {"
139 " var items = entries[i].querySelectorAll('tr > td');" 139 " var items = entries[i].querySelectorAll('tr > td');"
140 " var values = [];" 140 " var values = [];"
141 " for (var j = 0; j < items.length; ++j) {" 141 " for (var j = 0; j < items.length; ++j) {"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 "Platform", 281 "Platform",
282 values.Get(kUnknownPolicy), 282 values.Get(kUnknownPolicy),
283 true)); 283 true));
284 284
285 // Retrieve the contents of the policy table from the UI and verify that it 285 // Retrieve the contents of the policy table from the UI and verify that it
286 // matches the expectation. 286 // matches the expectation.
287 VerifyPolicies(expected_policies); 287 VerifyPolicies(expected_policies);
288 } 288 }
289 289
290 IN_PROC_BROWSER_TEST_F(PolicyUITest, ExtensionLoadAndSendPolicy) { 290 IN_PROC_BROWSER_TEST_F(PolicyUITest, ExtensionLoadAndSendPolicy) {
291 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIPolicyURL)); 291 ui_test_utils::NavigateToURL(browser(), GURL("chrome://policy"));
292 base::ScopedTempDir temp_dir_; 292 base::ScopedTempDir temp_dir_;
293 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 293 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
294 294
295 const std::string newly_added_policy_name = "new_policy"; 295 const std::string newly_added_policy_name = "new_policy";
296 std::string json_data = "{\"type\": \"object\",\"properties\": {\"" + 296 std::string json_data = "{\"type\": \"object\",\"properties\": {\"" +
297 newly_added_policy_name + 297 newly_added_policy_name +
298 "\": { \"type\": \"string\"}}}"; 298 "\": { \"type\": \"string\"}}}";
299 299
300 const std::string schema_file = "schema.json"; 300 const std::string schema_file = "schema.json";
301 base::FilePath schema_path = temp_dir_.path().AppendASCII(schema_file); 301 base::FilePath schema_path = temp_dir_.path().AppendASCII(schema_file);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 PopulateExpectedPolicy( 333 PopulateExpectedPolicy(
334 it.key(), std::string(), std::string(), nullptr, false)); 334 it.key(), std::string(), std::string(), nullptr, false));
335 } 335 }
336 // Add newly added policy to expected policy list. 336 // Add newly added policy to expected policy list.
337 expected_policies.push_back(PopulateExpectedPolicy( 337 expected_policies.push_back(PopulateExpectedPolicy(
338 newly_added_policy_name, std::string(), std::string(), nullptr, false)); 338 newly_added_policy_name, std::string(), std::string(), nullptr, false));
339 339
340 // Verify if policy UI includes policy that extension have. 340 // Verify if policy UI includes policy that extension have.
341 VerifyPolicies(expected_policies); 341 VerifyPolicies(expected_policies);
342 } 342 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698