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

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

Issue 102493002: Use schemas bundled in extensions to convert policies loaded on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added bug url Created 7 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 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 "components/policy/core/common/schema_internal.h" 7 #include "components/policy/core/common/schema_internal.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace policy { 10 namespace policy {
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 669
670 Schema list = schema.GetKnownProperty("list"); 670 Schema list = schema.GetKnownProperty("list");
671 ASSERT_TRUE(list.valid()); 671 ASSERT_TRUE(list.valid());
672 ASSERT_EQ(base::Value::TYPE_LIST, list.type()); 672 ASSERT_EQ(base::Value::TYPE_LIST, list.type());
673 673
674 Schema items = list.GetItems(); 674 Schema items = list.GetItems();
675 ASSERT_TRUE(items.valid()); 675 ASSERT_TRUE(items.valid());
676 ASSERT_EQ(base::Value::TYPE_BOOLEAN, items.type()); 676 ASSERT_EQ(base::Value::TYPE_BOOLEAN, items.type());
677 } 677 }
678 678
679 TEST(SchemaTest, BackwardsCompatibility) {
680 const char kTestSchema[] =
681 "{"
682 " \"type\": \"object\","
683 " \"properties\": {"
684 " \"magic\": { \"type\": \"array\" },"
685 " \"no magic\": {"
686 " \"type\": \"array\","
687 " \"items\": { \"type\": \"boolean\" }"
688 " }"
689 " }"
690 "}";
691
692 {
693 std::string error;
694 Schema schema = Schema::Parse(kTestSchema, &error);
695 EXPECT_FALSE(schema.valid());
696 EXPECT_FALSE(error.empty());
697 }
698
699 std::string error;
700 Schema schema = Schema::ParseWithBackwardsCompatibility(
701 kTestSchema, &error, true);
702 ASSERT_TRUE(schema.valid()) << error;
703
704 Schema magic = schema.GetProperty("magic");
705 ASSERT_TRUE(magic.valid());
706 ASSERT_EQ(base::Value::TYPE_LIST, magic.type());
707 Schema items = magic.GetItems();
708 ASSERT_TRUE(items.valid());
709 EXPECT_EQ(base::Value::TYPE_STRING, items.type());
710
711 Schema nomagic = schema.GetProperty("no magic");
712 ASSERT_TRUE(nomagic.valid());
713 ASSERT_EQ(base::Value::TYPE_LIST, nomagic.type());
714 items = nomagic.GetItems();
715 ASSERT_TRUE(items.valid());
716 EXPECT_EQ(base::Value::TYPE_BOOLEAN, items.type());
717 }
679 718
680 } // namespace policy 719 } // namespace policy
OLDNEW
« components/policy/core/common/schema.h ('K') | « components/policy/core/common/schema.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698