Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Side by Side Diff: components/policy/core/common/mac_util_unittest.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "base/mac/scoped_cftyperef.h" 11 #include "base/mac/scoped_cftyperef.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "components/policy/core/common/policy_test_utils.h" 13 #include "components/policy/core/common/policy_test_utils.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace policy { 16 namespace policy {
17 17
18 TEST(PolicyMacUtilTest, PropertyToValue) { 18 TEST(PolicyMacUtilTest, PropertyToValue) {
19 base::DictionaryValue root; 19 base::DictionaryValue root;
20 20
21 // base::Value::TYPE_NULL 21 // base::Value::Type::NONE
22 root.Set("null", base::Value::CreateNullValue()); 22 root.Set("null", base::Value::CreateNullValue());
23 23
24 // base::Value::TYPE_BOOLEAN 24 // base::Value::Type::BOOLEAN
25 root.SetBoolean("false", false); 25 root.SetBoolean("false", false);
26 root.SetBoolean("true", true); 26 root.SetBoolean("true", true);
27 27
28 // base::Value::TYPE_INTEGER 28 // base::Value::Type::INTEGER
29 root.SetInteger("int", 123); 29 root.SetInteger("int", 123);
30 root.SetInteger("zero", 0); 30 root.SetInteger("zero", 0);
31 31
32 // base::Value::TYPE_DOUBLE 32 // base::Value::Type::DOUBLE
33 root.SetDouble("double", 123.456); 33 root.SetDouble("double", 123.456);
34 root.SetDouble("zerod", 0.0); 34 root.SetDouble("zerod", 0.0);
35 35
36 // base::Value::TYPE_STRING 36 // base::Value::Type::STRING
37 root.SetString("string", "the fox jumps over something"); 37 root.SetString("string", "the fox jumps over something");
38 root.SetString("empty", ""); 38 root.SetString("empty", "");
39 39
40 // base::Value::TYPE_LIST 40 // base::Value::Type::LIST
41 base::ListValue list; 41 base::ListValue list;
42 root.Set("emptyl", list.DeepCopy()); 42 root.Set("emptyl", list.DeepCopy());
43 for (base::DictionaryValue::Iterator it(root); !it.IsAtEnd(); it.Advance()) 43 for (base::DictionaryValue::Iterator it(root); !it.IsAtEnd(); it.Advance())
44 list.Append(it.value().DeepCopy()); 44 list.Append(it.value().DeepCopy());
45 EXPECT_EQ(root.size(), list.GetSize()); 45 EXPECT_EQ(root.size(), list.GetSize());
46 list.Append(root.DeepCopy()); 46 list.Append(root.DeepCopy());
47 root.Set("list", list.DeepCopy()); 47 root.Set("list", list.DeepCopy());
48 48
49 // base::Value::TYPE_DICTIONARY 49 // base::Value::Type::DICTIONARY
50 base::DictionaryValue dict; 50 base::DictionaryValue dict;
51 root.Set("emptyd", dict.DeepCopy()); 51 root.Set("emptyd", dict.DeepCopy());
52 // Very meta. 52 // Very meta.
53 root.Set("dict", root.DeepCopy()); 53 root.Set("dict", root.DeepCopy());
54 54
55 base::ScopedCFTypeRef<CFPropertyListRef> property(ValueToProperty(root)); 55 base::ScopedCFTypeRef<CFPropertyListRef> property(ValueToProperty(root));
56 ASSERT_TRUE(property); 56 ASSERT_TRUE(property);
57 std::unique_ptr<base::Value> value = PropertyToValue(property); 57 std::unique_ptr<base::Value> value = PropertyToValue(property);
58 ASSERT_TRUE(value); 58 ASSERT_TRUE(value);
59 EXPECT_TRUE(root.Equals(value.get())); 59 EXPECT_TRUE(root.Equals(value.get()));
60 } 60 }
61 61
62 } // namespace policy 62 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698