| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 " values.push(item.textContent);" | 152 " values.push(item.textContent);" |
| 153 " }" | 153 " }" |
| 154 " policies.push(values);" | 154 " policies.push(values);" |
| 155 "}" | 155 "}" |
| 156 "domAutomationController.send(JSON.stringify(policies));"; | 156 "domAutomationController.send(JSON.stringify(policies));"; |
| 157 content::WebContents* contents = | 157 content::WebContents* contents = |
| 158 browser()->tab_strip_model()->GetActiveWebContents(); | 158 browser()->tab_strip_model()->GetActiveWebContents(); |
| 159 std::string json; | 159 std::string json; |
| 160 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents, javascript, | 160 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents, javascript, |
| 161 &json)); | 161 &json)); |
| 162 scoped_ptr<base::Value> value_ptr = base::JSONReader::Read(json); | 162 std::unique_ptr<base::Value> value_ptr = base::JSONReader::Read(json); |
| 163 const base::ListValue* actual_policies = NULL; | 163 const base::ListValue* actual_policies = NULL; |
| 164 ASSERT_TRUE(value_ptr.get()); | 164 ASSERT_TRUE(value_ptr.get()); |
| 165 ASSERT_TRUE(value_ptr->GetAsList(&actual_policies)); | 165 ASSERT_TRUE(value_ptr->GetAsList(&actual_policies)); |
| 166 | 166 |
| 167 // Verify that the cells contain the expected strings for all policies. | 167 // Verify that the cells contain the expected strings for all policies. |
| 168 ASSERT_EQ(expected_policies.size(), actual_policies->GetSize()); | 168 ASSERT_EQ(expected_policies.size(), actual_policies->GetSize()); |
| 169 for (size_t i = 0; i < expected_policies.size(); ++i) { | 169 for (size_t i = 0; i < expected_policies.size(); ++i) { |
| 170 const std::vector<std::string> expected_policy = expected_policies[i]; | 170 const std::vector<std::string> expected_policy = expected_policies[i]; |
| 171 const base::ListValue* actual_policy; | 171 const base::ListValue* actual_policy; |
| 172 ASSERT_TRUE(actual_policies->GetList(i, &actual_policy)); | 172 ASSERT_TRUE(actual_policies->GetList(i, &actual_policy)); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 PopulateExpectedPolicy( | 336 PopulateExpectedPolicy( |
| 337 it.key(), std::string(), std::string(), nullptr, false)); | 337 it.key(), std::string(), std::string(), nullptr, false)); |
| 338 } | 338 } |
| 339 // Add newly added policy to expected policy list. | 339 // Add newly added policy to expected policy list. |
| 340 expected_policies.push_back(PopulateExpectedPolicy( | 340 expected_policies.push_back(PopulateExpectedPolicy( |
| 341 newly_added_policy_name, std::string(), std::string(), nullptr, false)); | 341 newly_added_policy_name, std::string(), std::string(), nullptr, false)); |
| 342 | 342 |
| 343 // Verify if policy UI includes policy that extension have. | 343 // Verify if policy UI includes policy that extension have. |
| 344 VerifyPolicies(expected_policies); | 344 VerifyPolicies(expected_policies); |
| 345 } | 345 } |
| OLD | NEW |