| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/policy/device_management_policy_cache.h" | 5 #include "chrome/browser/policy/device_management_policy_cache.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/scoped_temp_dir.h" | 12 #include "base/scoped_temp_dir.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/browser_thread.h" | 14 #include "chrome/browser/browser_thread.h" |
| 15 #include "chrome/browser/policy/proto/device_management_constants.h" |
| 15 #include "chrome/browser/policy/proto/device_management_local.pb.h" | 16 #include "chrome/browser/policy/proto/device_management_local.pb.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 namespace policy { | 19 namespace policy { |
| 19 | 20 |
| 20 // Wraps base functionaly for the test cases. | 21 // Wraps base functionaly for the test cases. |
| 21 class DeviceManagementPolicyCacheTestBase : public testing::Test { | 22 class DeviceManagementPolicyCacheTestBase : public testing::Test { |
| 22 protected: | 23 protected: |
| 23 // Add a string policy setting to a policy response message. | 24 // Add a string policy setting to a policy response message. |
| 24 void AddStringPolicy(em::DevicePolicyResponse* policy, | 25 void AddStringPolicy(em::DevicePolicyResponse* policy, |
| 25 const std::string& name, | 26 const std::string& name, |
| 26 const std::string& value) { | 27 const std::string& value) { |
| 27 em::DevicePolicySetting* setting = policy->add_setting(); | 28 em::DevicePolicySetting* setting = policy->add_setting(); |
| 28 setting->set_policy_key("test"); | 29 setting->set_policy_key(kChromeDevicePolicySettingKey); |
| 29 em::GenericSetting* policy_value = setting->mutable_policy_value(); | 30 em::GenericSetting* policy_value = setting->mutable_policy_value(); |
| 30 em::GenericNamedValue* named_value = policy_value->add_named_value(); | 31 em::GenericNamedValue* named_value = policy_value->add_named_value(); |
| 31 named_value->set_name(name); | 32 named_value->set_name(name); |
| 32 em::GenericValue* value_container = named_value->mutable_value(); | 33 em::GenericValue* value_container = named_value->mutable_value(); |
| 33 value_container->set_value_type(em::GenericValue::VALUE_TYPE_STRING); | 34 value_container->set_value_type(em::GenericValue::VALUE_TYPE_STRING); |
| 34 value_container->set_string_value(value); | 35 value_container->set_string_value(value); |
| 35 } | 36 } |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 // Tests the device management policy cache. | 39 // Tests the device management policy cache. |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 em::DevicePolicyResponse policy; | 312 em::DevicePolicyResponse policy; |
| 312 AddStringPolicy(&policy, "HomepageLocation", "http://www.example.com"); | 313 AddStringPolicy(&policy, "HomepageLocation", "http://www.example.com"); |
| 313 scoped_ptr<Value> decoded(DeviceManagementPolicyCache::DecodePolicy(policy)); | 314 scoped_ptr<Value> decoded(DeviceManagementPolicyCache::DecodePolicy(policy)); |
| 314 DictionaryValue expected; | 315 DictionaryValue expected; |
| 315 expected.Set("HomepageLocation", | 316 expected.Set("HomepageLocation", |
| 316 Value::CreateStringValue("http://www.example.com")); | 317 Value::CreateStringValue("http://www.example.com")); |
| 317 EXPECT_TRUE(expected.Equals(decoded.get())); | 318 EXPECT_TRUE(expected.Equals(decoded.get())); |
| 318 } | 319 } |
| 319 | 320 |
| 320 } // namespace policy | 321 } // namespace policy |
| OLD | NEW |