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

Side by Side Diff: components/policy/core/browser/configuration_policy_handler_unittest.cc

Issue 1323923002: Remove use of JSONReader::DeprecatedRead from components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Error fix Created 5 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
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/prefs/pref_value_map.h" 9 #include "base/prefs/pref_value_map.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 Schema schema = Schema::Parse(kSchemaJson, &error); 645 Schema schema = Schema::Parse(kSchemaJson, &error);
646 ASSERT_TRUE(schema.valid()) << error; 646 ASSERT_TRUE(schema.valid()) << error;
647 647
648 static const char kPolicyMapJson[] = 648 static const char kPolicyMapJson[] =
649 "{" 649 "{"
650 " \"PolicyForTesting\": {" 650 " \"PolicyForTesting\": {"
651 " \"OneToThree\": 2," 651 " \"OneToThree\": 2,"
652 " \"Colors\": \"White\"" 652 " \"Colors\": \"White\""
653 " }" 653 " }"
654 "}"; 654 "}";
655 scoped_ptr<base::Value> policy_map_value( 655 scoped_ptr<base::Value> policy_map_value =
656 base::JSONReader::DeprecatedReadAndReturnError( 656 base::JSONReader::ReadAndReturnError(kPolicyMapJson, base::JSON_PARSE_RFC,
657 kPolicyMapJson, base::JSON_PARSE_RFC, NULL, &error)); 657 NULL, &error);
658 ASSERT_TRUE(policy_map_value) << error; 658 ASSERT_TRUE(policy_map_value) << error;
659 659
660 const base::DictionaryValue* policy_map_dict = NULL; 660 const base::DictionaryValue* policy_map_dict = NULL;
661 ASSERT_TRUE(policy_map_value->GetAsDictionary(&policy_map_dict)); 661 ASSERT_TRUE(policy_map_value->GetAsDictionary(&policy_map_dict));
662 662
663 PolicyMap policy_map; 663 PolicyMap policy_map;
664 policy_map.LoadFrom( 664 policy_map.LoadFrom(
665 policy_map_dict, POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_USER); 665 policy_map_dict, POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_USER);
666 666
667 TestSchemaValidatingPolicyHandler handler(schema, SCHEMA_ALLOW_INVALID); 667 TestSchemaValidatingPolicyHandler handler(schema, SCHEMA_ALLOW_INVALID);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 Schema schema = Schema::Parse(kSchemaJson, &error); 705 Schema schema = Schema::Parse(kSchemaJson, &error);
706 ASSERT_TRUE(schema.valid()) << error; 706 ASSERT_TRUE(schema.valid()) << error;
707 707
708 static const char kPolicyMapJson[] = 708 static const char kPolicyMapJson[] =
709 "{" 709 "{"
710 " \"PolicyForTesting\": {" 710 " \"PolicyForTesting\": {"
711 " \"OneToThree\": 2," 711 " \"OneToThree\": 2,"
712 " \"Colors\": \"Green\"" 712 " \"Colors\": \"Green\""
713 " }" 713 " }"
714 "}"; 714 "}";
715 scoped_ptr<base::Value> policy_map_value( 715 scoped_ptr<base::Value> policy_map_value =
716 base::JSONReader::DeprecatedReadAndReturnError( 716 base::JSONReader::ReadAndReturnError(kPolicyMapJson, base::JSON_PARSE_RFC,
717 kPolicyMapJson, base::JSON_PARSE_RFC, NULL, &error)); 717 NULL, &error);
718 ASSERT_TRUE(policy_map_value) << error; 718 ASSERT_TRUE(policy_map_value) << error;
719 719
720 const base::DictionaryValue* policy_map_dict = NULL; 720 const base::DictionaryValue* policy_map_dict = NULL;
721 ASSERT_TRUE(policy_map_value->GetAsDictionary(&policy_map_dict)); 721 ASSERT_TRUE(policy_map_value->GetAsDictionary(&policy_map_dict));
722 722
723 PolicyMap policy_map_recommended; 723 PolicyMap policy_map_recommended;
724 policy_map_recommended.LoadFrom( 724 policy_map_recommended.LoadFrom(
725 policy_map_dict, POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_USER); 725 policy_map_dict, POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_USER);
726 726
727 PolicyMap policy_map_mandatory; 727 PolicyMap policy_map_mandatory;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 handler_recommended.ApplyPolicySettings(policy_map_mandatory, &prefs); 810 handler_recommended.ApplyPolicySettings(policy_map_mandatory, &prefs);
811 EXPECT_TRUE(prefs.GetValue(kTestPref, &value_set_in_pref)); 811 EXPECT_TRUE(prefs.GetValue(kTestPref, &value_set_in_pref));
812 EXPECT_TRUE(value_expected_in_pref->Equals(value_set_in_pref)); 812 EXPECT_TRUE(value_expected_in_pref->Equals(value_set_in_pref));
813 813
814 EXPECT_FALSE( 814 EXPECT_FALSE(
815 handler_none.CheckPolicySettings(policy_map_recommended, &errors)); 815 handler_none.CheckPolicySettings(policy_map_recommended, &errors));
816 EXPECT_FALSE(errors.empty()); 816 EXPECT_FALSE(errors.empty());
817 } 817 }
818 818
819 } // namespace policy 819 } // namespace policy
OLDNEW
« no previous file with comments | « components/json_schema/json_schema_validator.cc ('k') | components/policy/core/common/cloud/component_cloud_policy_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698