| 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/policy/core/common/registry_dict_win.h" | 5 #include "components/policy/core/common/registry_dict_win.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "components/policy/core/common/schema.h" | 12 #include "components/policy/core/common/schema.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 namespace policy { | 15 namespace policy { |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 TEST(RegistryDictTest, SetAndGetValue) { | 18 TEST(RegistryDictTest, SetAndGetValue) { |
| 18 RegistryDict test_dict; | 19 RegistryDict test_dict; |
| 19 | 20 |
| 20 base::FundamentalValue int_value(42); | 21 base::FundamentalValue int_value(42); |
| 21 base::StringValue string_value("fortytwo"); | 22 base::StringValue string_value("fortytwo"); |
| 22 | 23 |
| 23 test_dict.SetValue("one", int_value.CreateDeepCopy()); | 24 test_dict.SetValue("one", int_value.CreateDeepCopy()); |
| 24 EXPECT_EQ(1u, test_dict.values().size()); | 25 EXPECT_EQ(1u, test_dict.values().size()); |
| 25 EXPECT_TRUE(base::Value::Equals(&int_value, test_dict.GetValue("one"))); | 26 EXPECT_TRUE(base::Value::Equals(&int_value, test_dict.GetValue("one"))); |
| 26 EXPECT_FALSE(test_dict.GetValue("two")); | 27 EXPECT_FALSE(test_dict.GetValue("two")); |
| 27 | 28 |
| 28 test_dict.SetValue("two", string_value.CreateDeepCopy()); | 29 test_dict.SetValue("two", string_value.CreateDeepCopy()); |
| 29 EXPECT_EQ(2u, test_dict.values().size()); | 30 EXPECT_EQ(2u, test_dict.values().size()); |
| 30 EXPECT_TRUE(base::Value::Equals(&int_value, test_dict.GetValue("one"))); | 31 EXPECT_TRUE(base::Value::Equals(&int_value, test_dict.GetValue("one"))); |
| 31 EXPECT_TRUE(base::Value::Equals(&string_value, test_dict.GetValue("two"))); | 32 EXPECT_TRUE(base::Value::Equals(&string_value, test_dict.GetValue("two"))); |
| 32 | 33 |
| 33 scoped_ptr<base::Value> one(test_dict.RemoveValue("one")); | 34 std::unique_ptr<base::Value> one(test_dict.RemoveValue("one")); |
| 34 EXPECT_EQ(1u, test_dict.values().size()); | 35 EXPECT_EQ(1u, test_dict.values().size()); |
| 35 EXPECT_TRUE(base::Value::Equals(&int_value, one.get())); | 36 EXPECT_TRUE(base::Value::Equals(&int_value, one.get())); |
| 36 EXPECT_FALSE(test_dict.GetValue("one")); | 37 EXPECT_FALSE(test_dict.GetValue("one")); |
| 37 EXPECT_TRUE(base::Value::Equals(&string_value, test_dict.GetValue("two"))); | 38 EXPECT_TRUE(base::Value::Equals(&string_value, test_dict.GetValue("two"))); |
| 38 | 39 |
| 39 test_dict.ClearValues(); | 40 test_dict.ClearValues(); |
| 40 EXPECT_FALSE(test_dict.GetValue("one")); | 41 EXPECT_FALSE(test_dict.GetValue("one")); |
| 41 EXPECT_FALSE(test_dict.GetValue("two")); | 42 EXPECT_FALSE(test_dict.GetValue("two")); |
| 42 EXPECT_TRUE(test_dict.values().empty()); | 43 EXPECT_TRUE(test_dict.values().empty()); |
| 43 } | 44 } |
| 44 | 45 |
| 45 TEST(RegistryDictTest, CaseInsensitiveButPreservingValueNames) { | 46 TEST(RegistryDictTest, CaseInsensitiveButPreservingValueNames) { |
| 46 RegistryDict test_dict; | 47 RegistryDict test_dict; |
| 47 | 48 |
| 48 base::FundamentalValue int_value(42); | 49 base::FundamentalValue int_value(42); |
| 49 base::StringValue string_value("fortytwo"); | 50 base::StringValue string_value("fortytwo"); |
| 50 | 51 |
| 51 test_dict.SetValue("One", int_value.CreateDeepCopy()); | 52 test_dict.SetValue("One", int_value.CreateDeepCopy()); |
| 52 EXPECT_EQ(1u, test_dict.values().size()); | 53 EXPECT_EQ(1u, test_dict.values().size()); |
| 53 EXPECT_TRUE(base::Value::Equals(&int_value, test_dict.GetValue("oNe"))); | 54 EXPECT_TRUE(base::Value::Equals(&int_value, test_dict.GetValue("oNe"))); |
| 54 | 55 |
| 55 RegistryDict::ValueMap::const_iterator entry = test_dict.values().begin(); | 56 RegistryDict::ValueMap::const_iterator entry = test_dict.values().begin(); |
| 56 ASSERT_NE(entry, test_dict.values().end()); | 57 ASSERT_NE(entry, test_dict.values().end()); |
| 57 EXPECT_EQ("One", entry->first); | 58 EXPECT_EQ("One", entry->first); |
| 58 | 59 |
| 59 test_dict.SetValue("ONE", string_value.CreateDeepCopy()); | 60 test_dict.SetValue("ONE", string_value.CreateDeepCopy()); |
| 60 EXPECT_EQ(1u, test_dict.values().size()); | 61 EXPECT_EQ(1u, test_dict.values().size()); |
| 61 EXPECT_TRUE(base::Value::Equals(&string_value, test_dict.GetValue("one"))); | 62 EXPECT_TRUE(base::Value::Equals(&string_value, test_dict.GetValue("one"))); |
| 62 | 63 |
| 63 scoped_ptr<base::Value> removed_value(test_dict.RemoveValue("onE")); | 64 std::unique_ptr<base::Value> removed_value(test_dict.RemoveValue("onE")); |
| 64 EXPECT_TRUE(base::Value::Equals(&string_value, removed_value.get())); | 65 EXPECT_TRUE(base::Value::Equals(&string_value, removed_value.get())); |
| 65 EXPECT_TRUE(test_dict.values().empty()); | 66 EXPECT_TRUE(test_dict.values().empty()); |
| 66 } | 67 } |
| 67 | 68 |
| 68 TEST(RegistryDictTest, SetAndGetKeys) { | 69 TEST(RegistryDictTest, SetAndGetKeys) { |
| 69 RegistryDict test_dict; | 70 RegistryDict test_dict; |
| 70 | 71 |
| 71 base::FundamentalValue int_value(42); | 72 base::FundamentalValue int_value(42); |
| 72 base::StringValue string_value("fortytwo"); | 73 base::StringValue string_value("fortytwo"); |
| 73 | 74 |
| 74 scoped_ptr<RegistryDict> subdict(new RegistryDict()); | 75 std::unique_ptr<RegistryDict> subdict(new RegistryDict()); |
| 75 subdict->SetValue("one", int_value.CreateDeepCopy()); | 76 subdict->SetValue("one", int_value.CreateDeepCopy()); |
| 76 test_dict.SetKey("two", std::move(subdict)); | 77 test_dict.SetKey("two", std::move(subdict)); |
| 77 EXPECT_EQ(1u, test_dict.keys().size()); | 78 EXPECT_EQ(1u, test_dict.keys().size()); |
| 78 RegistryDict* actual_subdict = test_dict.GetKey("two"); | 79 RegistryDict* actual_subdict = test_dict.GetKey("two"); |
| 79 ASSERT_TRUE(actual_subdict); | 80 ASSERT_TRUE(actual_subdict); |
| 80 EXPECT_TRUE(base::Value::Equals(&int_value, actual_subdict->GetValue("one"))); | 81 EXPECT_TRUE(base::Value::Equals(&int_value, actual_subdict->GetValue("one"))); |
| 81 | 82 |
| 82 subdict.reset(new RegistryDict()); | 83 subdict.reset(new RegistryDict()); |
| 83 subdict->SetValue("three", string_value.CreateDeepCopy()); | 84 subdict->SetValue("three", string_value.CreateDeepCopy()); |
| 84 test_dict.SetKey("four", std::move(subdict)); | 85 test_dict.SetKey("four", std::move(subdict)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 95 EXPECT_FALSE(test_dict.GetKey("one")); | 96 EXPECT_FALSE(test_dict.GetKey("one")); |
| 96 EXPECT_FALSE(test_dict.GetKey("three")); | 97 EXPECT_FALSE(test_dict.GetKey("three")); |
| 97 EXPECT_TRUE(test_dict.keys().empty()); | 98 EXPECT_TRUE(test_dict.keys().empty()); |
| 98 } | 99 } |
| 99 | 100 |
| 100 TEST(RegistryDictTest, CaseInsensitiveButPreservingKeyNames) { | 101 TEST(RegistryDictTest, CaseInsensitiveButPreservingKeyNames) { |
| 101 RegistryDict test_dict; | 102 RegistryDict test_dict; |
| 102 | 103 |
| 103 base::FundamentalValue int_value(42); | 104 base::FundamentalValue int_value(42); |
| 104 | 105 |
| 105 test_dict.SetKey("One", make_scoped_ptr(new RegistryDict())); | 106 test_dict.SetKey("One", base::WrapUnique(new RegistryDict())); |
| 106 EXPECT_EQ(1u, test_dict.keys().size()); | 107 EXPECT_EQ(1u, test_dict.keys().size()); |
| 107 RegistryDict* actual_subdict = test_dict.GetKey("One"); | 108 RegistryDict* actual_subdict = test_dict.GetKey("One"); |
| 108 ASSERT_TRUE(actual_subdict); | 109 ASSERT_TRUE(actual_subdict); |
| 109 EXPECT_TRUE(actual_subdict->values().empty()); | 110 EXPECT_TRUE(actual_subdict->values().empty()); |
| 110 | 111 |
| 111 RegistryDict::KeyMap::const_iterator entry = test_dict.keys().begin(); | 112 RegistryDict::KeyMap::const_iterator entry = test_dict.keys().begin(); |
| 112 ASSERT_NE(entry, test_dict.keys().end()); | 113 ASSERT_NE(entry, test_dict.keys().end()); |
| 113 EXPECT_EQ("One", entry->first); | 114 EXPECT_EQ("One", entry->first); |
| 114 | 115 |
| 115 scoped_ptr<RegistryDict> subdict(new RegistryDict()); | 116 std::unique_ptr<RegistryDict> subdict(new RegistryDict()); |
| 116 subdict->SetValue("two", int_value.CreateDeepCopy()); | 117 subdict->SetValue("two", int_value.CreateDeepCopy()); |
| 117 test_dict.SetKey("ONE", std::move(subdict)); | 118 test_dict.SetKey("ONE", std::move(subdict)); |
| 118 EXPECT_EQ(1u, test_dict.keys().size()); | 119 EXPECT_EQ(1u, test_dict.keys().size()); |
| 119 actual_subdict = test_dict.GetKey("One"); | 120 actual_subdict = test_dict.GetKey("One"); |
| 120 ASSERT_TRUE(actual_subdict); | 121 ASSERT_TRUE(actual_subdict); |
| 121 EXPECT_TRUE(base::Value::Equals(&int_value, | 122 EXPECT_TRUE(base::Value::Equals(&int_value, |
| 122 actual_subdict->GetValue("two"))); | 123 actual_subdict->GetValue("two"))); |
| 123 | 124 |
| 124 scoped_ptr<RegistryDict> removed_key(test_dict.RemoveKey("one")); | 125 std::unique_ptr<RegistryDict> removed_key(test_dict.RemoveKey("one")); |
| 125 ASSERT_TRUE(removed_key); | 126 ASSERT_TRUE(removed_key); |
| 126 EXPECT_TRUE(base::Value::Equals(&int_value, | 127 EXPECT_TRUE(base::Value::Equals(&int_value, |
| 127 removed_key->GetValue("two"))); | 128 removed_key->GetValue("two"))); |
| 128 EXPECT_TRUE(test_dict.keys().empty()); | 129 EXPECT_TRUE(test_dict.keys().empty()); |
| 129 } | 130 } |
| 130 | 131 |
| 131 TEST(RegistryDictTest, Merge) { | 132 TEST(RegistryDictTest, Merge) { |
| 132 RegistryDict dict_a; | 133 RegistryDict dict_a; |
| 133 RegistryDict dict_b; | 134 RegistryDict dict_b; |
| 134 | 135 |
| 135 base::FundamentalValue int_value(42); | 136 base::FundamentalValue int_value(42); |
| 136 base::StringValue string_value("fortytwo"); | 137 base::StringValue string_value("fortytwo"); |
| 137 | 138 |
| 138 dict_a.SetValue("one", int_value.CreateDeepCopy()); | 139 dict_a.SetValue("one", int_value.CreateDeepCopy()); |
| 139 scoped_ptr<RegistryDict> subdict(new RegistryDict()); | 140 std::unique_ptr<RegistryDict> subdict(new RegistryDict()); |
| 140 subdict->SetValue("two", string_value.CreateDeepCopy()); | 141 subdict->SetValue("two", string_value.CreateDeepCopy()); |
| 141 dict_a.SetKey("three", std::move(subdict)); | 142 dict_a.SetKey("three", std::move(subdict)); |
| 142 | 143 |
| 143 dict_b.SetValue("four", string_value.CreateDeepCopy()); | 144 dict_b.SetValue("four", string_value.CreateDeepCopy()); |
| 144 subdict.reset(new RegistryDict()); | 145 subdict.reset(new RegistryDict()); |
| 145 subdict->SetValue("two", int_value.CreateDeepCopy()); | 146 subdict->SetValue("two", int_value.CreateDeepCopy()); |
| 146 dict_b.SetKey("three", std::move(subdict)); | 147 dict_b.SetKey("three", std::move(subdict)); |
| 147 subdict.reset(new RegistryDict()); | 148 subdict.reset(new RegistryDict()); |
| 148 subdict->SetValue("five", int_value.CreateDeepCopy()); | 149 subdict->SetValue("five", int_value.CreateDeepCopy()); |
| 149 dict_b.SetKey("six", std::move(subdict)); | 150 dict_b.SetKey("six", std::move(subdict)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 162 } | 163 } |
| 163 | 164 |
| 164 TEST(RegistryDictTest, Swap) { | 165 TEST(RegistryDictTest, Swap) { |
| 165 RegistryDict dict_a; | 166 RegistryDict dict_a; |
| 166 RegistryDict dict_b; | 167 RegistryDict dict_b; |
| 167 | 168 |
| 168 base::FundamentalValue int_value(42); | 169 base::FundamentalValue int_value(42); |
| 169 base::StringValue string_value("fortytwo"); | 170 base::StringValue string_value("fortytwo"); |
| 170 | 171 |
| 171 dict_a.SetValue("one", int_value.CreateDeepCopy()); | 172 dict_a.SetValue("one", int_value.CreateDeepCopy()); |
| 172 dict_a.SetKey("two", make_scoped_ptr(new RegistryDict())); | 173 dict_a.SetKey("two", base::WrapUnique(new RegistryDict())); |
| 173 dict_b.SetValue("three", string_value.CreateDeepCopy()); | 174 dict_b.SetValue("three", string_value.CreateDeepCopy()); |
| 174 | 175 |
| 175 dict_a.Swap(&dict_b); | 176 dict_a.Swap(&dict_b); |
| 176 | 177 |
| 177 EXPECT_TRUE(base::Value::Equals(&int_value, dict_b.GetValue("one"))); | 178 EXPECT_TRUE(base::Value::Equals(&int_value, dict_b.GetValue("one"))); |
| 178 EXPECT_TRUE(dict_b.GetKey("two")); | 179 EXPECT_TRUE(dict_b.GetKey("two")); |
| 179 EXPECT_FALSE(dict_b.GetValue("two")); | 180 EXPECT_FALSE(dict_b.GetValue("two")); |
| 180 | 181 |
| 181 EXPECT_TRUE(base::Value::Equals(&string_value, dict_a.GetValue("three"))); | 182 EXPECT_TRUE(base::Value::Equals(&string_value, dict_a.GetValue("three"))); |
| 182 EXPECT_FALSE(dict_a.GetValue("one")); | 183 EXPECT_FALSE(dict_a.GetValue("one")); |
| 183 EXPECT_FALSE(dict_a.GetKey("two")); | 184 EXPECT_FALSE(dict_a.GetKey("two")); |
| 184 } | 185 } |
| 185 | 186 |
| 186 TEST(RegistryDictTest, ConvertToJSON) { | 187 TEST(RegistryDictTest, ConvertToJSON) { |
| 187 RegistryDict test_dict; | 188 RegistryDict test_dict; |
| 188 | 189 |
| 189 base::FundamentalValue int_value(42); | 190 base::FundamentalValue int_value(42); |
| 190 base::StringValue string_value("fortytwo"); | 191 base::StringValue string_value("fortytwo"); |
| 191 base::StringValue string_zero("0"); | 192 base::StringValue string_zero("0"); |
| 192 base::StringValue string_dict("{ \"key\": [ \"value\" ] }"); | 193 base::StringValue string_dict("{ \"key\": [ \"value\" ] }"); |
| 193 | 194 |
| 194 test_dict.SetValue("one", int_value.CreateDeepCopy()); | 195 test_dict.SetValue("one", int_value.CreateDeepCopy()); |
| 195 scoped_ptr<RegistryDict> subdict(new RegistryDict()); | 196 std::unique_ptr<RegistryDict> subdict(new RegistryDict()); |
| 196 subdict->SetValue("two", string_value.CreateDeepCopy()); | 197 subdict->SetValue("two", string_value.CreateDeepCopy()); |
| 197 test_dict.SetKey("three", std::move(subdict)); | 198 test_dict.SetKey("three", std::move(subdict)); |
| 198 scoped_ptr<RegistryDict> list(new RegistryDict()); | 199 std::unique_ptr<RegistryDict> list(new RegistryDict()); |
| 199 list->SetValue("1", string_value.CreateDeepCopy()); | 200 list->SetValue("1", string_value.CreateDeepCopy()); |
| 200 test_dict.SetKey("dict-to-list", std::move(list)); | 201 test_dict.SetKey("dict-to-list", std::move(list)); |
| 201 test_dict.SetValue("int-to-bool", int_value.CreateDeepCopy()); | 202 test_dict.SetValue("int-to-bool", int_value.CreateDeepCopy()); |
| 202 test_dict.SetValue("int-to-double", int_value.CreateDeepCopy()); | 203 test_dict.SetValue("int-to-double", int_value.CreateDeepCopy()); |
| 203 test_dict.SetValue("string-to-bool", string_zero.CreateDeepCopy()); | 204 test_dict.SetValue("string-to-bool", string_zero.CreateDeepCopy()); |
| 204 test_dict.SetValue("string-to-double", string_zero.CreateDeepCopy()); | 205 test_dict.SetValue("string-to-double", string_zero.CreateDeepCopy()); |
| 205 test_dict.SetValue("string-to-int", string_zero.CreateDeepCopy()); | 206 test_dict.SetValue("string-to-int", string_zero.CreateDeepCopy()); |
| 206 test_dict.SetValue("string-to-dict", string_dict.CreateDeepCopy()); | 207 test_dict.SetValue("string-to-dict", string_dict.CreateDeepCopy()); |
| 207 | 208 |
| 208 std::string error; | 209 std::string error; |
| 209 Schema schema = Schema::Parse( | 210 Schema schema = Schema::Parse( |
| 210 "{" | 211 "{" |
| 211 " \"type\": \"object\"," | 212 " \"type\": \"object\"," |
| 212 " \"properties\": {" | 213 " \"properties\": {" |
| 213 " \"dict-to-list\": {" | 214 " \"dict-to-list\": {" |
| 214 " \"type\": \"array\"," | 215 " \"type\": \"array\"," |
| 215 " \"items\": { \"type\": \"string\" }" | 216 " \"items\": { \"type\": \"string\" }" |
| 216 " }," | 217 " }," |
| 217 " \"int-to-bool\": { \"type\": \"boolean\" }," | 218 " \"int-to-bool\": { \"type\": \"boolean\" }," |
| 218 " \"int-to-double\": { \"type\": \"number\" }," | 219 " \"int-to-double\": { \"type\": \"number\" }," |
| 219 " \"string-to-bool\": { \"type\": \"boolean\" }," | 220 " \"string-to-bool\": { \"type\": \"boolean\" }," |
| 220 " \"string-to-double\": { \"type\": \"number\" }," | 221 " \"string-to-double\": { \"type\": \"number\" }," |
| 221 " \"string-to-int\": { \"type\": \"integer\" }," | 222 " \"string-to-int\": { \"type\": \"integer\" }," |
| 222 " \"string-to-dict\": { \"type\": \"object\" }" | 223 " \"string-to-dict\": { \"type\": \"object\" }" |
| 223 " }" | 224 " }" |
| 224 "}", &error); | 225 "}", &error); |
| 225 ASSERT_TRUE(schema.valid()) << error; | 226 ASSERT_TRUE(schema.valid()) << error; |
| 226 | 227 |
| 227 scoped_ptr<base::Value> actual(test_dict.ConvertToJSON(schema)); | 228 std::unique_ptr<base::Value> actual(test_dict.ConvertToJSON(schema)); |
| 228 | 229 |
| 229 base::DictionaryValue expected; | 230 base::DictionaryValue expected; |
| 230 expected.Set("one", int_value.CreateDeepCopy()); | 231 expected.Set("one", int_value.CreateDeepCopy()); |
| 231 scoped_ptr<base::DictionaryValue> expected_subdict( | 232 std::unique_ptr<base::DictionaryValue> expected_subdict( |
| 232 new base::DictionaryValue()); | 233 new base::DictionaryValue()); |
| 233 expected_subdict->Set("two", string_value.CreateDeepCopy()); | 234 expected_subdict->Set("two", string_value.CreateDeepCopy()); |
| 234 expected.Set("three", std::move(expected_subdict)); | 235 expected.Set("three", std::move(expected_subdict)); |
| 235 scoped_ptr<base::ListValue> expected_list(new base::ListValue()); | 236 std::unique_ptr<base::ListValue> expected_list(new base::ListValue()); |
| 236 expected_list->Append(string_value.CreateDeepCopy()); | 237 expected_list->Append(string_value.CreateDeepCopy()); |
| 237 expected.Set("dict-to-list", std::move(expected_list)); | 238 expected.Set("dict-to-list", std::move(expected_list)); |
| 238 expected.Set("int-to-bool", new base::FundamentalValue(true)); | 239 expected.Set("int-to-bool", new base::FundamentalValue(true)); |
| 239 expected.Set("int-to-double", new base::FundamentalValue(42.0)); | 240 expected.Set("int-to-double", new base::FundamentalValue(42.0)); |
| 240 expected.Set("string-to-bool", new base::FundamentalValue(false)); | 241 expected.Set("string-to-bool", new base::FundamentalValue(false)); |
| 241 expected.Set("string-to-double", new base::FundamentalValue(0.0)); | 242 expected.Set("string-to-double", new base::FundamentalValue(0.0)); |
| 242 expected.Set("string-to-int", | 243 expected.Set("string-to-int", |
| 243 new base::FundamentalValue(static_cast<int>(0))); | 244 new base::FundamentalValue(static_cast<int>(0))); |
| 244 expected_list.reset(new base::ListValue()); | 245 expected_list.reset(new base::ListValue()); |
| 245 expected_list->Append(new base::StringValue("value")); | 246 expected_list->Append(new base::StringValue("value")); |
| 246 expected_subdict.reset(new base::DictionaryValue()); | 247 expected_subdict.reset(new base::DictionaryValue()); |
| 247 expected_subdict->Set("key", std::move(expected_list)); | 248 expected_subdict->Set("key", std::move(expected_list)); |
| 248 expected.Set("string-to-dict", std::move(expected_subdict)); | 249 expected.Set("string-to-dict", std::move(expected_subdict)); |
| 249 | 250 |
| 250 EXPECT_TRUE(base::Value::Equals(actual.get(), &expected)); | 251 EXPECT_TRUE(base::Value::Equals(actual.get(), &expected)); |
| 251 } | 252 } |
| 252 | 253 |
| 253 TEST(RegistryDictTest, KeyValueNameClashes) { | 254 TEST(RegistryDictTest, KeyValueNameClashes) { |
| 254 RegistryDict test_dict; | 255 RegistryDict test_dict; |
| 255 | 256 |
| 256 base::FundamentalValue int_value(42); | 257 base::FundamentalValue int_value(42); |
| 257 base::StringValue string_value("fortytwo"); | 258 base::StringValue string_value("fortytwo"); |
| 258 | 259 |
| 259 test_dict.SetValue("one", int_value.CreateDeepCopy()); | 260 test_dict.SetValue("one", int_value.CreateDeepCopy()); |
| 260 scoped_ptr<RegistryDict> subdict(new RegistryDict()); | 261 std::unique_ptr<RegistryDict> subdict(new RegistryDict()); |
| 261 subdict->SetValue("two", string_value.CreateDeepCopy()); | 262 subdict->SetValue("two", string_value.CreateDeepCopy()); |
| 262 test_dict.SetKey("one", std::move(subdict)); | 263 test_dict.SetKey("one", std::move(subdict)); |
| 263 | 264 |
| 264 EXPECT_TRUE(base::Value::Equals(&int_value, test_dict.GetValue("one"))); | 265 EXPECT_TRUE(base::Value::Equals(&int_value, test_dict.GetValue("one"))); |
| 265 RegistryDict* actual_subdict = test_dict.GetKey("one"); | 266 RegistryDict* actual_subdict = test_dict.GetKey("one"); |
| 266 ASSERT_TRUE(actual_subdict); | 267 ASSERT_TRUE(actual_subdict); |
| 267 EXPECT_TRUE(base::Value::Equals(&string_value, | 268 EXPECT_TRUE(base::Value::Equals(&string_value, |
| 268 actual_subdict->GetValue("two"))); | 269 actual_subdict->GetValue("two"))); |
| 269 } | 270 } |
| 270 | 271 |
| 271 } // namespace | 272 } // namespace |
| 272 } // namespace policy | 273 } // namespace policy |
| OLD | NEW |