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

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

Issue 171403004: Add touch flag to output of Schema::Normalize() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split-1
Patch Set: Created 6 years, 10 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
« no previous file with comments | « components/policy/core/common/schema.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "components/policy/core/common/schema_internal.h" 8 #include "components/policy/core/common/schema_internal.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 // Test that Schema::Validate() works as expected. 122 // Test that Schema::Validate() works as expected.
123 error = kNoErrorReturned; 123 error = kNoErrorReturned;
124 bool returned = schema.Validate(value, strategy, NULL, &error); 124 bool returned = schema.Validate(value, strategy, NULL, &error);
125 EXPECT_EQ(returned, expected_return_value) << error; 125 EXPECT_EQ(returned, expected_return_value) << error;
126 126
127 // Test that Schema::Normalize() will return the same value as 127 // Test that Schema::Normalize() will return the same value as
128 // Schema::Validate(). 128 // Schema::Validate().
129 error = kNoErrorReturned; 129 error = kNoErrorReturned;
130 scoped_ptr<base::Value> cloned_value(value.DeepCopy()); 130 scoped_ptr<base::Value> cloned_value(value.DeepCopy());
131 returned = schema.Normalize(cloned_value.get(), strategy, NULL, &error); 131 returned = schema.Normalize(cloned_value.get(), strategy, NULL, &error, NULL);
Joao da Silva 2014/02/20 12:46:41 Add tests that verify the |changed| argument
binjin 2014/02/20 15:48:34 Done.
132 EXPECT_EQ(returned, expected_return_value) << error; 132 EXPECT_EQ(returned, expected_return_value) << error;
133 133
134 // Test that Schema::Normalize() have actually dropped invalid and unknown 134 // Test that Schema::Normalize() have actually dropped invalid and unknown
135 // properties. 135 // properties.
136 if (expected_return_value) { 136 if (expected_return_value) {
137 EXPECT_TRUE( 137 EXPECT_TRUE(
138 schema.Validate(*cloned_value.get(), SCHEMA_STRICT, NULL, &error)); 138 schema.Validate(*cloned_value.get(), SCHEMA_STRICT, NULL, &error));
139 EXPECT_TRUE( 139 EXPECT_TRUE(schema.Normalize(
140 schema.Normalize(cloned_value.get(), SCHEMA_STRICT, NULL, &error)); 140 cloned_value.get(), SCHEMA_STRICT, NULL, &error, NULL));
141 } 141 }
142 } 142 }
143 143
144 void TestSchemaValidationWithPath(Schema schema, 144 void TestSchemaValidationWithPath(Schema schema,
145 const base::Value& value, 145 const base::Value& value,
146 const std::string& expected_failure_path) { 146 const std::string& expected_failure_path) {
147 std::string error_path = "NOT_SET"; 147 std::string error_path = "NOT_SET";
148 std::string error; 148 std::string error;
149 149
150 bool returned = schema.Validate(value, SCHEMA_STRICT, &error_path, &error); 150 bool returned = schema.Validate(value, SCHEMA_STRICT, &error_path, &error);
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 1045
1046 EXPECT_FALSE(ParseFails(SchemaObjectWrapper( 1046 EXPECT_FALSE(ParseFails(SchemaObjectWrapper(
1047 "{" 1047 "{"
1048 " \"type\": \"integer\"," 1048 " \"type\": \"integer\","
1049 " \"minimum\": 10," 1049 " \"minimum\": 10,"
1050 " \"maximum\": 20" 1050 " \"maximum\": 20"
1051 "}"))); 1051 "}")));
1052 } 1052 }
1053 1053
1054 } // namespace policy 1054 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/schema.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698