| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/mac_util.h" | 5 #include "components/policy/core/common/mac_util.h" |
| 6 | 6 |
| 7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 // base::Value::Type::DOUBLE | 33 // base::Value::Type::DOUBLE |
| 34 root.SetDouble("double", 123.456); | 34 root.SetDouble("double", 123.456); |
| 35 root.SetDouble("zerod", 0.0); | 35 root.SetDouble("zerod", 0.0); |
| 36 | 36 |
| 37 // base::Value::Type::STRING | 37 // base::Value::Type::STRING |
| 38 root.SetString("string", "the fox jumps over something"); | 38 root.SetString("string", "the fox jumps over something"); |
| 39 root.SetString("empty", ""); | 39 root.SetString("empty", ""); |
| 40 | 40 |
| 41 // base::Value::Type::LIST | 41 // base::Value::Type::LIST |
| 42 root.Set("emptyl", base::MakeUnique<base::Value>(base::Value::Type::LIST)); |
| 42 base::ListValue list; | 43 base::ListValue list; |
| 43 root.Set("emptyl", list.DeepCopy()); | |
| 44 for (base::DictionaryValue::Iterator it(root); !it.IsAtEnd(); it.Advance()) | 44 for (base::DictionaryValue::Iterator it(root); !it.IsAtEnd(); it.Advance()) |
| 45 list.Append(it.value().DeepCopy()); | 45 list.Append(base::MakeUnique<base::Value>(it.value())); |
| 46 EXPECT_EQ(root.size(), list.GetSize()); | 46 EXPECT_EQ(root.size(), list.GetSize()); |
| 47 list.Append(root.DeepCopy()); | 47 list.Append(base::MakeUnique<base::Value>(root)); |
| 48 root.Set("list", list.DeepCopy()); | 48 root.Set("list", base::MakeUnique<base::Value>(list)); |
| 49 | 49 |
| 50 // base::Value::Type::DICTIONARY | 50 // base::Value::Type::DICTIONARY |
| 51 base::DictionaryValue dict; | 51 root.Set("emptyd", |
| 52 root.Set("emptyd", dict.DeepCopy()); | 52 base::MakeUnique<base::Value>(base::Value::Type::DICTIONARY)); |
| 53 // Very meta. | 53 // Very meta. |
| 54 root.Set("dict", root.DeepCopy()); | 54 root.Set("dict", base::MakeUnique<base::Value>(root)); |
| 55 | 55 |
| 56 base::ScopedCFTypeRef<CFPropertyListRef> property(ValueToProperty(root)); | 56 base::ScopedCFTypeRef<CFPropertyListRef> property(ValueToProperty(root)); |
| 57 ASSERT_TRUE(property); | 57 ASSERT_TRUE(property); |
| 58 std::unique_ptr<base::Value> value = PropertyToValue(property); | 58 std::unique_ptr<base::Value> value = PropertyToValue(property); |
| 59 ASSERT_TRUE(value); | 59 ASSERT_TRUE(value); |
| 60 EXPECT_TRUE(root.Equals(value.get())); | 60 EXPECT_TRUE(root.Equals(value.get())); |
| 61 } | 61 } |
| 62 | 62 |
| 63 } // namespace policy | 63 } // namespace policy |
| OLD | NEW |