OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/user_policy_cache.h" | 5 #include "chrome/browser/policy/user_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" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 EXPECT_TRUE(mandatory.Equals(mandatory_policy)); | 160 EXPECT_TRUE(mandatory.Equals(mandatory_policy)); |
161 EXPECT_TRUE(recommended.Equals(recommended_policy)); | 161 EXPECT_TRUE(recommended.Equals(recommended_policy)); |
162 } | 162 } |
163 | 163 |
164 TEST_F(UserPolicyCacheTest, DecodeIntegerValue) { | 164 TEST_F(UserPolicyCacheTest, DecodeIntegerValue) { |
165 const int min = std::numeric_limits<int>::min(); | 165 const int min = std::numeric_limits<int>::min(); |
166 const int max = std::numeric_limits<int>::max(); | 166 const int max = std::numeric_limits<int>::max(); |
167 scoped_ptr<Value> value( | 167 scoped_ptr<Value> value( |
168 DecodeIntegerValue(static_cast<google::protobuf::int64>(42))); | 168 DecodeIntegerValue(static_cast<google::protobuf::int64>(42))); |
169 ASSERT_TRUE(value.get()); | 169 ASSERT_TRUE(value.get()); |
170 FundamentalValue expected_42(42); | 170 base::FundamentalValue expected_42(42); |
171 EXPECT_TRUE(value->Equals(&expected_42)); | 171 EXPECT_TRUE(value->Equals(&expected_42)); |
172 value.reset( | 172 value.reset( |
173 DecodeIntegerValue(static_cast<google::protobuf::int64>(min - 1LL))); | 173 DecodeIntegerValue(static_cast<google::protobuf::int64>(min - 1LL))); |
174 EXPECT_EQ(NULL, value.get()); | 174 EXPECT_EQ(NULL, value.get()); |
175 value.reset(DecodeIntegerValue(static_cast<google::protobuf::int64>(min))); | 175 value.reset(DecodeIntegerValue(static_cast<google::protobuf::int64>(min))); |
176 ASSERT_TRUE(value.get()); | 176 ASSERT_TRUE(value.get()); |
177 FundamentalValue expected_min(min); | 177 base::FundamentalValue expected_min(min); |
178 EXPECT_TRUE(value->Equals(&expected_min)); | 178 EXPECT_TRUE(value->Equals(&expected_min)); |
179 value.reset( | 179 value.reset( |
180 DecodeIntegerValue(static_cast<google::protobuf::int64>(max + 1LL))); | 180 DecodeIntegerValue(static_cast<google::protobuf::int64>(max + 1LL))); |
181 EXPECT_EQ(NULL, value.get()); | 181 EXPECT_EQ(NULL, value.get()); |
182 value.reset(DecodeIntegerValue(static_cast<google::protobuf::int64>(max))); | 182 value.reset(DecodeIntegerValue(static_cast<google::protobuf::int64>(max))); |
183 ASSERT_TRUE(value.get()); | 183 ASSERT_TRUE(value.get()); |
184 FundamentalValue expected_max(max); | 184 base::FundamentalValue expected_max(max); |
185 EXPECT_TRUE(value->Equals(&expected_max)); | 185 EXPECT_TRUE(value->Equals(&expected_max)); |
186 } | 186 } |
187 | 187 |
188 TEST_F(UserPolicyCacheTest, DecodeStringList) { | 188 TEST_F(UserPolicyCacheTest, DecodeStringList) { |
189 em::StringList string_list; | 189 em::StringList string_list; |
190 string_list.add_entries("ponies"); | 190 string_list.add_entries("ponies"); |
191 string_list.add_entries("more ponies"); | 191 string_list.add_entries("more ponies"); |
192 scoped_ptr<ListValue> decoded(DecodeStringList(string_list)); | 192 scoped_ptr<ListValue> decoded(DecodeStringList(string_list)); |
193 ListValue expected; | 193 ListValue expected; |
194 expected.Append(Value::CreateStringValue("ponies")); | 194 expected.Append(Value::CreateStringValue("ponies")); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 // If new-style policy comes in, it should override old-style policy. | 378 // If new-style policy comes in, it should override old-style policy. |
379 policy = CreateHomepagePolicy("http://www.example.com", | 379 policy = CreateHomepagePolicy("http://www.example.com", |
380 base::Time::NowFromSystemTime(), | 380 base::Time::NowFromSystemTime(), |
381 em::PolicyOptions::RECOMMENDED); | 381 em::PolicyOptions::RECOMMENDED); |
382 SetPolicy(&cache, policy, true); | 382 SetPolicy(&cache, policy, true); |
383 EXPECT_TRUE(expected.Equals(recommended_policy(cache))); | 383 EXPECT_TRUE(expected.Equals(recommended_policy(cache))); |
384 EXPECT_TRUE(empty.Equals(mandatory_policy(cache))); | 384 EXPECT_TRUE(empty.Equals(mandatory_policy(cache))); |
385 } | 385 } |
386 | 386 |
387 } // namespace policy | 387 } // namespace policy |
OLD | NEW |