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

Side by Side Diff: chrome/browser/policy/registry_dict_win_unittest.cc

Issue 22645011: policy: use JSON schema to deserialize entries from Windows registry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix 3rd party policy unit tests Created 7 years, 3 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 | « chrome/browser/policy/registry_dict_win.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 "chrome/browser/policy/registry_dict_win.h" 5 #include "chrome/browser/policy/registry_dict_win.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "components/json_schema/json_schema_constants.h" 8 #include "components/json_schema/json_schema_constants.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 base::StringValue string_value("fortytwo"); 189 base::StringValue string_value("fortytwo");
190 190
191 test_dict.SetValue("one", make_scoped_ptr(int_value.DeepCopy())); 191 test_dict.SetValue("one", make_scoped_ptr(int_value.DeepCopy()));
192 scoped_ptr<RegistryDict> subdict(new RegistryDict()); 192 scoped_ptr<RegistryDict> subdict(new RegistryDict());
193 subdict->SetValue("two", make_scoped_ptr(string_value.DeepCopy())); 193 subdict->SetValue("two", make_scoped_ptr(string_value.DeepCopy()));
194 test_dict.SetKey("three", subdict.Pass()); 194 test_dict.SetKey("three", subdict.Pass());
195 scoped_ptr<RegistryDict> list(new RegistryDict()); 195 scoped_ptr<RegistryDict> list(new RegistryDict());
196 list->SetValue("1", make_scoped_ptr(string_value.DeepCopy())); 196 list->SetValue("1", make_scoped_ptr(string_value.DeepCopy()));
197 test_dict.SetKey("four", list.Pass()); 197 test_dict.SetKey("four", list.Pass());
198 198
199 base::DictionaryValue schema; 199 std::string err = "";
200 scoped_ptr<base::DictionaryValue> list_schema(new base::DictionaryValue()); 200 scoped_ptr<PolicySchema> schema(PolicySchema::Parse(
201 list_schema->SetString(schema::kType, schema::kArray); 201 "{\n"
202 scoped_ptr<base::DictionaryValue> properties(new base::DictionaryValue()); 202 " \"$schema\": \"http://json-schema.org/draft-03/schema#\",\n"
203 properties->Set("four", list_schema.release()); 203 " \"type\": \"object\",\n"
204 schema.SetString(schema::kType, schema::kObject); 204 " \"properties\": {\n"
205 schema.Set(schema::kProperties, properties.release()); 205 " \"four\": {\n"
206 " \"type\": \"array\",\n"
207 " \"items\": { \"type\": \"string\" }\n"
208 " }\n"
209 " }\n"
210 "}\n",
211 &err));
212 EXPECT_EQ("", err);
206 213
207 scoped_ptr<base::Value> actual(test_dict.ConvertToJSON(&schema)); 214 scoped_ptr<base::Value> actual(test_dict.ConvertToJSON(schema.get()));
208 215
209 base::DictionaryValue expected; 216 base::DictionaryValue expected;
210 expected.Set("one", int_value.DeepCopy()); 217 expected.Set("one", int_value.DeepCopy());
211 scoped_ptr<base::DictionaryValue> expected_subdict( 218 scoped_ptr<base::DictionaryValue> expected_subdict(
212 new base::DictionaryValue()); 219 new base::DictionaryValue());
213 expected_subdict->Set("two", string_value.DeepCopy()); 220 expected_subdict->Set("two", string_value.DeepCopy());
214 expected.Set("three", expected_subdict.release()); 221 expected.Set("three", expected_subdict.release());
215 scoped_ptr<base::ListValue> expected_list(new base::ListValue()); 222 scoped_ptr<base::ListValue> expected_list(new base::ListValue());
216 expected_list->Append(string_value.DeepCopy()); 223 expected_list->Append(string_value.DeepCopy());
217 expected.Set("four", expected_list.release()); 224 expected.Set("four", expected_list.release());
(...skipping 14 matching lines...) Expand all
232 239
233 EXPECT_TRUE(base::Value::Equals(&int_value, test_dict.GetValue("one"))); 240 EXPECT_TRUE(base::Value::Equals(&int_value, test_dict.GetValue("one")));
234 RegistryDict* actual_subdict = test_dict.GetKey("one"); 241 RegistryDict* actual_subdict = test_dict.GetKey("one");
235 ASSERT_TRUE(actual_subdict); 242 ASSERT_TRUE(actual_subdict);
236 EXPECT_TRUE(base::Value::Equals(&string_value, 243 EXPECT_TRUE(base::Value::Equals(&string_value,
237 actual_subdict->GetValue("two"))); 244 actual_subdict->GetValue("two")));
238 } 245 }
239 246
240 } // namespace 247 } // namespace
241 } // namespace policy 248 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/registry_dict_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698