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

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

Issue 31273002: Generate the Chrome policy schema at compile time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/policy/browser_policy_connector.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h"
9 #include "components/policy/core/common/schema.h"
10 #include "policy/policy_constants.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 // This unittest tests the code generated by
14 // chrome/tools/build/generate_policy_source.py.
15
16 namespace policy {
17
18 TEST(GeneratePolicySource, ChromeSchemaData) {
19 scoped_ptr<SchemaOwner> schema_owner =
20 SchemaOwner::Wrap(GetChromeSchemaData());
21 ASSERT_TRUE(schema_owner);
22
23 Schema schema = schema_owner->schema();
24 EXPECT_EQ(base::Value::TYPE_DICTIONARY, schema.type());
25
26 Schema subschema = schema.GetAdditionalProperties();
27 EXPECT_FALSE(subschema.valid());
28
29 subschema = schema.GetProperty("no such policy exists");
30 EXPECT_FALSE(subschema.valid());
31
32 subschema = schema.GetProperty(key::kAlternateErrorPagesEnabled);
33 ASSERT_TRUE(subschema.valid());
34 EXPECT_EQ(base::Value::TYPE_BOOLEAN, subschema.type());
35
36 subschema = schema.GetProperty(key::kIncognitoModeAvailability);
37 ASSERT_TRUE(subschema.valid());
38 EXPECT_EQ(base::Value::TYPE_INTEGER, subschema.type());
39
40 subschema = schema.GetProperty(key::kProxyMode);
41 ASSERT_TRUE(subschema.valid());
42 EXPECT_EQ(base::Value::TYPE_STRING, subschema.type());
43
44 subschema = schema.GetProperty(key::kCookiesAllowedForUrls);
45 ASSERT_TRUE(subschema.valid());
46 EXPECT_EQ(base::Value::TYPE_LIST, subschema.type());
47 ASSERT_TRUE(subschema.GetItems().valid());
48 EXPECT_EQ(base::Value::TYPE_STRING, subschema.GetItems().type());
49
50 subschema = schema.GetProperty(key::kProxySettings);
51 ASSERT_TRUE(subschema.valid());
52 EXPECT_EQ(base::Value::TYPE_DICTIONARY, subschema.type());
53 EXPECT_FALSE(subschema.GetAdditionalProperties().valid());
54 EXPECT_FALSE(subschema.GetProperty("no such proxy key exists").valid());
55 ASSERT_TRUE(subschema.GetProperty(key::kProxyMode).valid());
56 ASSERT_TRUE(subschema.GetProperty(key::kProxyServer).valid());
57 ASSERT_TRUE(subschema.GetProperty(key::kProxyServerMode).valid());
58 ASSERT_TRUE(subschema.GetProperty(key::kProxyPacUrl).valid());
59 ASSERT_TRUE(subschema.GetProperty(key::kProxyBypassList).valid());
60
61 // The properties are iterated in order.
62 const char* kExpectedProperties[] = {
63 key::kProxyBypassList,
64 key::kProxyMode,
65 key::kProxyPacUrl,
66 key::kProxyServer,
67 key::kProxyServerMode,
68 NULL,
69 };
70 const char** next = kExpectedProperties;
71 for (Schema::Iterator it(subschema.GetPropertiesIterator());
72 !it.IsAtEnd(); it.Advance(), ++next) {
73 ASSERT_TRUE(*next != NULL);
74 EXPECT_STREQ(*next, it.key());
75 ASSERT_TRUE(it.schema().valid());
76 EXPECT_EQ(base::Value::TYPE_STRING, it.schema().type());
77 }
78 EXPECT_TRUE(*next == NULL);
79 }
80
81 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/browser_policy_connector.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698