OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/user_prefs/tracked/pref_hash_calculator.h" | 5 #include "components/user_prefs/tracked/pref_hash_calculator.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 dict_value->Set("b", new base::DictionaryValue); | 104 dict_value->Set("b", new base::DictionaryValue); |
105 dict_value->Set("c", new base::StringValue("baz")); | 105 dict_value->Set("c", new base::StringValue("baz")); |
106 dict_value->Set("e", nested_empty_dict.release()); | 106 dict_value->Set("e", nested_empty_dict.release()); |
107 dict_value->Set("f", nested_empty_list.release()); | 107 dict_value->Set("f", nested_empty_list.release()); |
108 | 108 |
109 std::unique_ptr<base::ListValue> list_value(new base::ListValue); | 109 std::unique_ptr<base::ListValue> list_value(new base::ListValue); |
110 list_value->AppendBoolean(true); | 110 list_value->AppendBoolean(true); |
111 list_value->AppendInteger(100); | 111 list_value->AppendInteger(100); |
112 list_value->AppendDouble(1.0); | 112 list_value->AppendDouble(1.0); |
113 | 113 |
114 ASSERT_EQ(base::Value::TYPE_NULL, null_value->GetType()); | 114 ASSERT_EQ(base::Value::Type::NONE, null_value->GetType()); |
115 ASSERT_EQ(base::Value::TYPE_BOOLEAN, bool_value->GetType()); | 115 ASSERT_EQ(base::Value::Type::BOOLEAN, bool_value->GetType()); |
116 ASSERT_EQ(base::Value::TYPE_INTEGER, int_value->GetType()); | 116 ASSERT_EQ(base::Value::Type::INTEGER, int_value->GetType()); |
117 ASSERT_EQ(base::Value::TYPE_DOUBLE, double_value->GetType()); | 117 ASSERT_EQ(base::Value::Type::DOUBLE, double_value->GetType()); |
118 ASSERT_EQ(base::Value::TYPE_STRING, string_value->GetType()); | 118 ASSERT_EQ(base::Value::Type::STRING, string_value->GetType()); |
119 ASSERT_EQ(base::Value::TYPE_DICTIONARY, dict_value->GetType()); | 119 ASSERT_EQ(base::Value::Type::DICTIONARY, dict_value->GetType()); |
120 ASSERT_EQ(base::Value::TYPE_LIST, list_value->GetType()); | 120 ASSERT_EQ(base::Value::Type::LIST, list_value->GetType()); |
121 | 121 |
122 // Test every value type independently. Intentionally omits TYPE_BINARY which | 122 // Test every value type independently. Intentionally omits Type::BINARY which |
123 // isn't even allowed in JSONWriter's input. | 123 // isn't even allowed in JSONWriter's input. |
124 static const char kExpectedNullValue[] = | 124 static const char kExpectedNullValue[] = |
125 "82A9F3BBC7F9FF84C76B033C854E79EEB162783FA7B3E99FF9372FA8E12C44F7"; | 125 "82A9F3BBC7F9FF84C76B033C854E79EEB162783FA7B3E99FF9372FA8E12C44F7"; |
126 EXPECT_EQ(PrefHashCalculator::VALID, | 126 EXPECT_EQ(PrefHashCalculator::VALID, |
127 PrefHashCalculator(kSeed, kDeviceId) | 127 PrefHashCalculator(kSeed, kDeviceId) |
128 .Validate("pref.path", null_value.get(), kExpectedNullValue)); | 128 .Validate("pref.path", null_value.get(), kExpectedNullValue)); |
129 | 129 |
130 static const char kExpectedBooleanValue[] = | 130 static const char kExpectedBooleanValue[] = |
131 "A520D8F43EA307B0063736DC9358C330539D0A29417580514C8B9862632C4CCC"; | 131 "A520D8F43EA307B0063736DC9358C330539D0A29417580514C8B9862632C4CCC"; |
132 EXPECT_EQ( | 132 EXPECT_EQ( |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 "845EF34663FF8D32BE6707F40258FBA531C2BFC532E3B014AFB3476115C2A9DE"; | 196 "845EF34663FF8D32BE6707F40258FBA531C2BFC532E3B014AFB3476115C2A9DE"; |
197 | 197 |
198 base::ListValue startup_urls; | 198 base::ListValue startup_urls; |
199 startup_urls.Set(0, new base::StringValue("http://www.chromium.org/")); | 199 startup_urls.Set(0, new base::StringValue("http://www.chromium.org/")); |
200 | 200 |
201 EXPECT_EQ( | 201 EXPECT_EQ( |
202 PrefHashCalculator::VALID_SECURE_LEGACY, | 202 PrefHashCalculator::VALID_SECURE_LEGACY, |
203 PrefHashCalculator(std::string(kSeed, arraysize(kSeed)), kDeviceId) | 203 PrefHashCalculator(std::string(kSeed, arraysize(kSeed)), kDeviceId) |
204 .Validate("session.startup_urls", &startup_urls, kExpectedValue)); | 204 .Validate("session.startup_urls", &startup_urls, kExpectedValue)); |
205 } | 205 } |
OLD | NEW |