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

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

Issue 2030833003: Remove ListValue::Append(new {Fundamental,String}Value(...)) pattern in //components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months 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 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/schema.h" 5 #include "components/policy/core/common/schema.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 // Tests on ObjectOfArray. 797 // Tests on ObjectOfArray.
798 { 798 {
799 Schema subschema = schema.GetProperty("ObjectOfArray"); 799 Schema subschema = schema.GetProperty("ObjectOfArray");
800 ASSERT_TRUE(subschema.valid()); 800 ASSERT_TRUE(subschema.valid());
801 base::DictionaryValue root; 801 base::DictionaryValue root;
802 802
803 base::ListValue* list_value = new base::ListValue(); 803 base::ListValue* list_value = new base::ListValue();
804 root.Set("List", list_value); // Pass ownership to root. 804 root.Set("List", list_value); // Pass ownership to root.
805 805
806 // Test that there are not errors here. 806 // Test that there are not errors here.
807 list_value->Append(new base::FundamentalValue(12345)); 807 list_value->AppendInteger(12345);
808 TestSchemaValidation(subschema, root, SCHEMA_STRICT, true); 808 TestSchemaValidation(subschema, root, SCHEMA_STRICT, true);
809 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN_TOPLEVEL, true); 809 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN_TOPLEVEL, true);
810 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN, true); 810 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN, true);
811 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID_TOPLEVEL, true); 811 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID_TOPLEVEL, true);
812 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID, true); 812 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID, true);
813 813
814 // Invalid list item. 814 // Invalid list item.
815 list_value->Append(new base::StringValue("blabla")); 815 list_value->AppendString("blabla");
816 TestSchemaValidation(subschema, root, SCHEMA_STRICT, false); 816 TestSchemaValidation(subschema, root, SCHEMA_STRICT, false);
817 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN_TOPLEVEL, false); 817 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN_TOPLEVEL, false);
818 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN, false); 818 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN, false);
819 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID_TOPLEVEL, true); 819 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID_TOPLEVEL, true);
820 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID, true); 820 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID, true);
821 TestSchemaValidationWithPath(subschema, root, "List.items[1]"); 821 TestSchemaValidationWithPath(subschema, root, "List.items[1]");
822 } 822 }
823 823
824 // Tests on ArrayOfObjectOfArray. 824 // Tests on ArrayOfObjectOfArray.
825 { 825 {
826 Schema subschema = schema.GetProperty("ArrayOfObjectOfArray"); 826 Schema subschema = schema.GetProperty("ArrayOfObjectOfArray");
827 ASSERT_TRUE(subschema.valid()); 827 ASSERT_TRUE(subschema.valid());
828 base::ListValue root; 828 base::ListValue root;
829 829
830 base::ListValue* list_value = new base::ListValue(); 830 base::ListValue* list_value = new base::ListValue();
831 base::DictionaryValue* dict_value = new base::DictionaryValue(); 831 base::DictionaryValue* dict_value = new base::DictionaryValue();
832 dict_value->Set("List", list_value); // Pass ownership to dict_value. 832 dict_value->Set("List", list_value); // Pass ownership to dict_value.
833 root.Append(dict_value); // Pass ownership to root. 833 root.Append(dict_value); // Pass ownership to root.
834 834
835 // Test that there are not errors here. 835 // Test that there are not errors here.
836 list_value->Append(new base::StringValue("blabla")); 836 list_value->AppendString("blabla");
837 TestSchemaValidation(subschema, root, SCHEMA_STRICT, true); 837 TestSchemaValidation(subschema, root, SCHEMA_STRICT, true);
838 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN_TOPLEVEL, true); 838 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN_TOPLEVEL, true);
839 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN, true); 839 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN, true);
840 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID_TOPLEVEL, true); 840 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID_TOPLEVEL, true);
841 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID, true); 841 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID, true);
842 842
843 // Invalid list item. 843 // Invalid list item.
844 list_value->Append(new base::FundamentalValue(12345)); 844 list_value->AppendInteger(12345);
845 TestSchemaValidation(subschema, root, SCHEMA_STRICT, false); 845 TestSchemaValidation(subschema, root, SCHEMA_STRICT, false);
846 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN_TOPLEVEL, false); 846 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN_TOPLEVEL, false);
847 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN, false); 847 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_UNKNOWN, false);
848 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID_TOPLEVEL, true); 848 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID_TOPLEVEL, true);
849 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID, true); 849 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID, true);
850 TestSchemaValidationWithPath(subschema, root, "items[0].List.items[1]"); 850 TestSchemaValidationWithPath(subschema, root, "items[0].List.items[1]");
851 } 851 }
852 852
853 // Tests on StringWithPattern. 853 // Tests on StringWithPattern.
854 { 854 {
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 1174
1175 EXPECT_FALSE(ParseFails(SchemaObjectWrapper( 1175 EXPECT_FALSE(ParseFails(SchemaObjectWrapper(
1176 "{" 1176 "{"
1177 " \"type\": \"integer\"," 1177 " \"type\": \"integer\","
1178 " \"minimum\": 10," 1178 " \"minimum\": 10,"
1179 " \"maximum\": 20" 1179 " \"maximum\": 20"
1180 "}"))); 1180 "}")));
1181 } 1181 }
1182 1182
1183 } // namespace policy 1183 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/browser/configuration_policy_pref_store_unittest.cc ('k') | components/prefs/pref_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698