| 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/callback.h" | 5 #include "base/callback.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 return base::StringPrintf(kTestPolicy, | 132 return base::StringPrintf(kTestPolicy, |
| 133 dm_protocol::kChromeUserPolicyType, | 133 dm_protocol::kChromeUserPolicyType, |
| 134 homepage, | 134 homepage, |
| 135 GetTestUser(), | 135 GetTestUser(), |
| 136 key_version); | 136 key_version); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void GetExpectedDefaultPolicy(PolicyMap* policy_map) { | 139 void GetExpectedDefaultPolicy(PolicyMap* policy_map) { |
| 140 #if defined(OS_CHROMEOS) | 140 #if defined(OS_CHROMEOS) |
| 141 policy_map->Set( | 141 policy_map->Set(key::kChromeOsMultiProfileUserBehavior, |
| 142 key::kChromeOsMultiProfileUserBehavior, POLICY_LEVEL_MANDATORY, | 142 POLICY_LEVEL_MANDATORY, |
| 143 POLICY_SCOPE_USER, base::Value::CreateStringValue("primary-only"), NULL); | 143 POLICY_SCOPE_USER, |
| 144 new base::StringValue("primary-only"), |
| 145 NULL); |
| 144 #endif | 146 #endif |
| 145 } | 147 } |
| 146 | 148 |
| 147 void GetExpectedTestPolicy(PolicyMap* expected, const char* homepage) { | 149 void GetExpectedTestPolicy(PolicyMap* expected, const char* homepage) { |
| 148 expected->Set(key::kShowHomeButton, | 150 expected->Set(key::kShowHomeButton, |
| 149 POLICY_LEVEL_MANDATORY, | 151 POLICY_LEVEL_MANDATORY, |
| 150 POLICY_SCOPE_USER, | 152 POLICY_SCOPE_USER, |
| 151 new base::FundamentalValue(true), | 153 new base::FundamentalValue(true), |
| 152 NULL); | 154 NULL); |
| 153 expected->Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, | 155 expected->Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, |
| 154 POLICY_SCOPE_USER, base::Value::CreateIntegerValue(4), NULL); | 156 POLICY_SCOPE_USER, base::Value::CreateIntegerValue(4), NULL); |
| 155 base::ListValue list; | 157 base::ListValue list; |
| 156 list.AppendString("dev.chromium.org"); | 158 list.AppendString("dev.chromium.org"); |
| 157 list.AppendString("youtube.com"); | 159 list.AppendString("youtube.com"); |
| 158 expected->Set( | 160 expected->Set( |
| 159 key::kURLBlacklist, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 161 key::kURLBlacklist, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 160 list.DeepCopy(), NULL); | 162 list.DeepCopy(), NULL); |
| 161 expected->Set( | 163 expected->Set( |
| 162 key::kMaxInvalidationFetchDelay, POLICY_LEVEL_MANDATORY, | 164 key::kMaxInvalidationFetchDelay, POLICY_LEVEL_MANDATORY, |
| 163 POLICY_SCOPE_USER, base::Value::CreateIntegerValue(1000), NULL); | 165 POLICY_SCOPE_USER, base::Value::CreateIntegerValue(1000), NULL); |
| 164 expected->Set( | 166 expected->Set(key::kHomepageLocation, |
| 165 key::kHomepageLocation, POLICY_LEVEL_RECOMMENDED, | 167 POLICY_LEVEL_RECOMMENDED, |
| 166 POLICY_SCOPE_USER, base::Value::CreateStringValue(homepage), NULL); | 168 POLICY_SCOPE_USER, |
| 169 new base::StringValue(homepage), |
| 170 NULL); |
| 167 #if defined(OS_CHROMEOS) | 171 #if defined(OS_CHROMEOS) |
| 168 expected->Set( | 172 expected->Set(key::kChromeOsMultiProfileUserBehavior, |
| 169 key::kChromeOsMultiProfileUserBehavior, POLICY_LEVEL_MANDATORY, | 173 POLICY_LEVEL_MANDATORY, |
| 170 POLICY_SCOPE_USER, base::Value::CreateStringValue("primary-only"), NULL); | 174 POLICY_SCOPE_USER, |
| 175 new base::StringValue("primary-only"), |
| 176 NULL); |
| 171 #endif | 177 #endif |
| 172 } | 178 } |
| 173 | 179 |
| 174 } // namespace | 180 } // namespace |
| 175 | 181 |
| 176 // Tests the cloud policy stack(s). | 182 // Tests the cloud policy stack(s). |
| 177 class CloudPolicyTest : public InProcessBrowserTest, | 183 class CloudPolicyTest : public InProcessBrowserTest, |
| 178 public PolicyService::Observer { | 184 public PolicyService::Observer { |
| 179 protected: | 185 protected: |
| 180 CloudPolicyTest() {} | 186 CloudPolicyTest() {} |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 | 468 |
| 463 // They should now serialize to the same bytes. | 469 // They should now serialize to the same bytes. |
| 464 std::string chrome_settings_serialized; | 470 std::string chrome_settings_serialized; |
| 465 std::string cloud_policy_serialized; | 471 std::string cloud_policy_serialized; |
| 466 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); | 472 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); |
| 467 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); | 473 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); |
| 468 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); | 474 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); |
| 469 } | 475 } |
| 470 | 476 |
| 471 } // namespace policy | 477 } // namespace policy |
| OLD | NEW |