| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/json/json_string_value_serializer.h" | 8 #include "base/json/json_string_value_serializer.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 138 |
| 139 void TestHarness::WriteConfigFile(const base::DictionaryValue& dict, | 139 void TestHarness::WriteConfigFile(const base::DictionaryValue& dict, |
| 140 const std::string& file_name) { | 140 const std::string& file_name) { |
| 141 std::string data; | 141 std::string data; |
| 142 JSONStringValueSerializer serializer(&data); | 142 JSONStringValueSerializer serializer(&data); |
| 143 serializer.Serialize(dict); | 143 serializer.Serialize(dict); |
| 144 const base::FilePath mandatory_dir(test_dir().Append(kMandatoryPath)); | 144 const base::FilePath mandatory_dir(test_dir().Append(kMandatoryPath)); |
| 145 ASSERT_TRUE(base::CreateDirectory(mandatory_dir)); | 145 ASSERT_TRUE(base::CreateDirectory(mandatory_dir)); |
| 146 const base::FilePath file_path(mandatory_dir.AppendASCII(file_name)); | 146 const base::FilePath file_path(mandatory_dir.AppendASCII(file_name)); |
| 147 ASSERT_EQ((int) data.size(), | 147 ASSERT_EQ((int) data.size(), |
| 148 file_util::WriteFile(file_path, data.c_str(), data.size())); | 148 base::WriteFile(file_path, data.c_str(), data.size())); |
| 149 } | 149 } |
| 150 | 150 |
| 151 std::string TestHarness::NextConfigFileName() { | 151 std::string TestHarness::NextConfigFileName() { |
| 152 EXPECT_LE(next_policy_file_index_, 999); | 152 EXPECT_LE(next_policy_file_index_, 999); |
| 153 return std::string("policy") + base::IntToString(next_policy_file_index_++); | 153 return std::string("policy") + base::IntToString(next_policy_file_index_++); |
| 154 } | 154 } |
| 155 | 155 |
| 156 // static | 156 // static |
| 157 PolicyProviderTestHarness* TestHarness::Create() { | 157 PolicyProviderTestHarness* TestHarness::Create() { |
| 158 return new TestHarness(); | 158 return new TestHarness(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 loop_.message_loop_proxy(), harness_.test_dir(), POLICY_SCOPE_USER); | 227 loop_.message_loop_proxy(), harness_.test_dir(), POLICY_SCOPE_USER); |
| 228 scoped_ptr<PolicyBundle> bundle(loader.Load()); | 228 scoped_ptr<PolicyBundle> bundle(loader.Load()); |
| 229 ASSERT_TRUE(bundle.get()); | 229 ASSERT_TRUE(bundle.get()); |
| 230 PolicyBundle expected_bundle; | 230 PolicyBundle expected_bundle; |
| 231 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 231 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
| 232 .LoadFrom(&test_dict_foo, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); | 232 .LoadFrom(&test_dict_foo, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); |
| 233 EXPECT_TRUE(bundle->Equals(expected_bundle)); | 233 EXPECT_TRUE(bundle->Equals(expected_bundle)); |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace policy | 236 } // namespace policy |
| OLD | NEW |