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 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIPolicyURL)); | 282 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIPolicyURL)); |
283 base::ScopedTempDir temp_dir_; | 283 base::ScopedTempDir temp_dir_; |
284 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 284 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
285 | 285 |
286 const std::string newly_added_policy_name = "new_policy"; | 286 const std::string newly_added_policy_name = "new_policy"; |
287 std::string json_data = "{\"type\": \"object\",\"properties\": {\"" + | 287 std::string json_data = "{\"type\": \"object\",\"properties\": {\"" + |
288 newly_added_policy_name + | 288 newly_added_policy_name + |
289 "\": { \"type\": \"string\"}}}"; | 289 "\": { \"type\": \"string\"}}}"; |
290 | 290 |
291 const std::string schema_file = "schema.json"; | 291 const std::string schema_file = "schema.json"; |
292 base::FilePath schema_path = temp_dir_.path().AppendASCII(schema_file); | 292 base::FilePath schema_path = temp_dir_.GetPath().AppendASCII(schema_file); |
293 base::WriteFile(schema_path, json_data.data(), json_data.size()); | 293 base::WriteFile(schema_path, json_data.data(), json_data.size()); |
294 | 294 |
295 // Build extension that contains the policy schema. | 295 // Build extension that contains the policy schema. |
296 extensions::DictionaryBuilder storage; | 296 extensions::DictionaryBuilder storage; |
297 storage.Set("managed_schema", schema_file); | 297 storage.Set("managed_schema", schema_file); |
298 | 298 |
299 extensions::DictionaryBuilder manifest; | 299 extensions::DictionaryBuilder manifest; |
300 manifest.Set("name", "test") | 300 manifest.Set("name", "test") |
301 .Set("version", "1") | 301 .Set("version", "1") |
302 .Set("manifest_version", 2) | 302 .Set("manifest_version", 2) |
303 .Set("storage", storage.Build()); | 303 .Set("storage", storage.Build()); |
304 | 304 |
305 extensions::ExtensionBuilder builder; | 305 extensions::ExtensionBuilder builder; |
306 builder.SetPath(temp_dir_.path()); | 306 builder.SetPath(temp_dir_.GetPath()); |
307 builder.SetManifest(manifest.Build()); | 307 builder.SetManifest(manifest.Build()); |
308 | 308 |
309 // Install extension. | 309 // Install extension. |
310 ExtensionService* service = extensions::ExtensionSystem::Get( | 310 ExtensionService* service = extensions::ExtensionSystem::Get( |
311 browser()->profile())->extension_service(); | 311 browser()->profile())->extension_service(); |
312 EXPECT_CALL(provider_, RefreshPolicies()); | 312 EXPECT_CALL(provider_, RefreshPolicies()); |
313 service->OnExtensionInstalled(builder.Build().get(), syncer::StringOrdinal(), | 313 service->OnExtensionInstalled(builder.Build().get(), syncer::StringOrdinal(), |
314 0); | 314 0); |
315 | 315 |
316 std::vector<std::vector<std::string>> expected_policies; | 316 std::vector<std::vector<std::string>> expected_policies; |
317 policy::Schema chrome_schema = | 317 policy::Schema chrome_schema = |
318 policy::Schema::Wrap(policy::GetChromeSchemaData()); | 318 policy::Schema::Wrap(policy::GetChromeSchemaData()); |
319 ASSERT_TRUE(chrome_schema.valid()); | 319 ASSERT_TRUE(chrome_schema.valid()); |
320 | 320 |
321 for (policy::Schema::Iterator it = chrome_schema.GetPropertiesIterator(); | 321 for (policy::Schema::Iterator it = chrome_schema.GetPropertiesIterator(); |
322 !it.IsAtEnd(); it.Advance()) { | 322 !it.IsAtEnd(); it.Advance()) { |
323 expected_policies.push_back( | 323 expected_policies.push_back( |
324 PopulateExpectedPolicy( | 324 PopulateExpectedPolicy( |
325 it.key(), std::string(), std::string(), nullptr, false)); | 325 it.key(), std::string(), std::string(), nullptr, false)); |
326 } | 326 } |
327 // Add newly added policy to expected policy list. | 327 // Add newly added policy to expected policy list. |
328 expected_policies.push_back(PopulateExpectedPolicy( | 328 expected_policies.push_back(PopulateExpectedPolicy( |
329 newly_added_policy_name, std::string(), std::string(), nullptr, false)); | 329 newly_added_policy_name, std::string(), std::string(), nullptr, false)); |
330 | 330 |
331 // Verify if policy UI includes policy that extension have. | 331 // Verify if policy UI includes policy that extension have. |
332 VerifyPolicies(expected_policies); | 332 VerifyPolicies(expected_policies); |
333 } | 333 } |
OLD | NEW |