| OLD | NEW |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/threading/thread_restrictions.h" |
| 17 #include "base/values.h" | 18 #include "base/values.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/extensions/test_extension_system.h" | 20 #include "chrome/browser/extensions/test_extension_system.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 23 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 24 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
| 25 #include "chrome/test/base/ui_test_utils.h" | 26 #include "chrome/test/base/ui_test_utils.h" |
| 26 #include "components/policy/core/browser/browser_policy_connector.h" | 27 #include "components/policy/core/browser/browser_policy_connector.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 values.Get(kUnknownPolicy), | 274 values.Get(kUnknownPolicy), |
| 274 true)); | 275 true)); |
| 275 | 276 |
| 276 // Retrieve the contents of the policy table from the UI and verify that it | 277 // Retrieve the contents of the policy table from the UI and verify that it |
| 277 // matches the expectation. | 278 // matches the expectation. |
| 278 VerifyPolicies(expected_policies); | 279 VerifyPolicies(expected_policies); |
| 279 } | 280 } |
| 280 | 281 |
| 281 IN_PROC_BROWSER_TEST_F(PolicyUITest, ExtensionLoadAndSendPolicy) { | 282 IN_PROC_BROWSER_TEST_F(PolicyUITest, ExtensionLoadAndSendPolicy) { |
| 282 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIPolicyURL)); | 283 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIPolicyURL)); |
| 284 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 283 base::ScopedTempDir temp_dir_; | 285 base::ScopedTempDir temp_dir_; |
| 284 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 286 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 285 | 287 |
| 286 const std::string newly_added_policy_name = "new_policy"; | 288 const std::string newly_added_policy_name = "new_policy"; |
| 287 std::string json_data = "{\"type\": \"object\",\"properties\": {\"" + | 289 std::string json_data = "{\"type\": \"object\",\"properties\": {\"" + |
| 288 newly_added_policy_name + | 290 newly_added_policy_name + |
| 289 "\": { \"type\": \"string\"}}}"; | 291 "\": { \"type\": \"string\"}}}"; |
| 290 | 292 |
| 291 const std::string schema_file = "schema.json"; | 293 const std::string schema_file = "schema.json"; |
| 292 base::FilePath schema_path = temp_dir_.GetPath().AppendASCII(schema_file); | 294 base::FilePath schema_path = temp_dir_.GetPath().AppendASCII(schema_file); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 PopulateExpectedPolicy( | 326 PopulateExpectedPolicy( |
| 325 it.key(), std::string(), std::string(), nullptr, false)); | 327 it.key(), std::string(), std::string(), nullptr, false)); |
| 326 } | 328 } |
| 327 // Add newly added policy to expected policy list. | 329 // Add newly added policy to expected policy list. |
| 328 expected_policies.push_back(PopulateExpectedPolicy( | 330 expected_policies.push_back(PopulateExpectedPolicy( |
| 329 newly_added_policy_name, std::string(), std::string(), nullptr, false)); | 331 newly_added_policy_name, std::string(), std::string(), nullptr, false)); |
| 330 | 332 |
| 331 // Verify if policy UI includes policy that extension have. | 333 // Verify if policy UI includes policy that extension have. |
| 332 VerifyPolicies(expected_policies); | 334 VerifyPolicies(expected_policies); |
| 333 } | 335 } |
| OLD | NEW |