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

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

Issue 573933002: Cleanup: Remove remaining generated extensions APIs on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@extclean4
Patch Set: fix build some more after rebasing Created 6 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/autocomplete/shortcuts_provider_unittest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 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/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "chrome/browser/policy/managed_bookmarks_policy_handler.h" 6 #include "chrome/browser/policy/managed_bookmarks_policy_handler.h"
7 #include "components/bookmarks/common/bookmark_pref_names.h" 7 #include "components/bookmarks/common/bookmark_pref_names.h"
8 #include "components/policy/core/browser/configuration_policy_pref_store.h" 8 #include "components/policy/core/browser/configuration_policy_pref_store.h"
9 #include "components/policy/core/browser/configuration_policy_pref_store_test.h" 9 #include "components/policy/core/browser/configuration_policy_pref_store_test.h"
10 #include "components/policy/core/common/policy_map.h" 10 #include "components/policy/core/common/policy_map.h"
11 #include "components/policy/core/common/schema.h" 11 #include "components/policy/core/common/schema.h"
12 #include "policy/policy_constants.h"
13
14 #if defined(ENABLE_EXTENSIONS)
12 #include "extensions/common/value_builder.h" 15 #include "extensions/common/value_builder.h"
13 #include "policy/policy_constants.h" 16 #endif
14 17
15 namespace policy { 18 namespace policy {
16 19
17 class ManagedBookmarksPolicyHandlerTest 20 class ManagedBookmarksPolicyHandlerTest
18 : public ConfigurationPolicyPrefStoreTest { 21 : public ConfigurationPolicyPrefStoreTest {
19 virtual void SetUp() OVERRIDE { 22 virtual void SetUp() OVERRIDE {
20 Schema chrome_schema = Schema::Wrap(GetChromeSchemaData()); 23 Schema chrome_schema = Schema::Wrap(GetChromeSchemaData());
21 handler_list_.AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>( 24 handler_list_.AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
22 new ManagedBookmarksPolicyHandler(chrome_schema))); 25 new ManagedBookmarksPolicyHandler(chrome_schema)));
23 } 26 }
24 }; 27 };
25 28
29 #if defined(ENABLE_EXTENSIONS)
26 TEST_F(ManagedBookmarksPolicyHandlerTest, ApplyPolicySettings) { 30 TEST_F(ManagedBookmarksPolicyHandlerTest, ApplyPolicySettings) {
27 EXPECT_FALSE(store_->GetValue(bookmarks::prefs::kManagedBookmarks, NULL)); 31 EXPECT_FALSE(store_->GetValue(bookmarks::prefs::kManagedBookmarks, NULL));
28 32
29 PolicyMap policy; 33 PolicyMap policy;
30 policy.Set(key::kManagedBookmarks, 34 policy.Set(key::kManagedBookmarks,
31 POLICY_LEVEL_MANDATORY, 35 POLICY_LEVEL_MANDATORY,
32 POLICY_SCOPE_USER, 36 POLICY_SCOPE_USER,
33 base::JSONReader::Read( 37 base::JSONReader::Read(
34 "[" 38 "["
35 " {" 39 " {"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 .Set("name", "Bugs") 98 .Set("name", "Bugs")
95 .Set("url", "http://crbug.com/") 99 .Set("url", "http://crbug.com/")
96 .Pass()) 100 .Pass())
97 .Pass()) 101 .Pass())
98 .Pass()) 102 .Pass())
99 .Pass()) 103 .Pass())
100 .Pass()) 104 .Pass())
101 .Build()); 105 .Build());
102 EXPECT_TRUE(pref_value->Equals(expected.get())); 106 EXPECT_TRUE(pref_value->Equals(expected.get()));
103 } 107 }
108 #endif // defined(ENABLE_EXTENSIONS)
104 109
105 TEST_F(ManagedBookmarksPolicyHandlerTest, WrongPolicyType) { 110 TEST_F(ManagedBookmarksPolicyHandlerTest, WrongPolicyType) {
106 PolicyMap policy; 111 PolicyMap policy;
107 // The expected type is base::ListValue, but this policy sets it as an 112 // The expected type is base::ListValue, but this policy sets it as an
108 // unparsed base::StringValue. Any type other than ListValue should fail. 113 // unparsed base::StringValue. Any type other than ListValue should fail.
109 policy.Set(key::kManagedBookmarks, 114 policy.Set(key::kManagedBookmarks,
110 POLICY_LEVEL_MANDATORY, 115 POLICY_LEVEL_MANDATORY,
111 POLICY_SCOPE_USER, 116 POLICY_SCOPE_USER,
112 new base::StringValue( 117 new base::StringValue(
113 "[" 118 "["
114 " {" 119 " {"
115 " \"name\": \"Google\"," 120 " \"name\": \"Google\","
116 " \"url\": \"google.com\"" 121 " \"url\": \"google.com\""
117 " }," 122 " },"
118 "]"), 123 "]"),
119 NULL); 124 NULL);
120 UpdateProviderPolicy(policy); 125 UpdateProviderPolicy(policy);
121 EXPECT_FALSE(store_->GetValue(bookmarks::prefs::kManagedBookmarks, NULL)); 126 EXPECT_FALSE(store_->GetValue(bookmarks::prefs::kManagedBookmarks, NULL));
122 } 127 }
123 128
129 #if defined(ENABLE_EXTENSIONS)
124 TEST_F(ManagedBookmarksPolicyHandlerTest, UnknownKeys) { 130 TEST_F(ManagedBookmarksPolicyHandlerTest, UnknownKeys) {
125 PolicyMap policy; 131 PolicyMap policy;
126 policy.Set(key::kManagedBookmarks, 132 policy.Set(key::kManagedBookmarks,
127 POLICY_LEVEL_MANDATORY, 133 POLICY_LEVEL_MANDATORY,
128 POLICY_SCOPE_USER, 134 POLICY_SCOPE_USER,
129 base::JSONReader::Read( 135 base::JSONReader::Read(
130 "[" 136 "["
131 " {" 137 " {"
132 " \"name\": \"Google\"," 138 " \"name\": \"Google\","
133 " \"unknown\": \"should be ignored\"," 139 " \"unknown\": \"should be ignored\","
134 " \"url\": \"google.com\"" 140 " \"url\": \"google.com\""
135 " }" 141 " }"
136 "]"), 142 "]"),
137 NULL); 143 NULL);
138 UpdateProviderPolicy(policy); 144 UpdateProviderPolicy(policy);
139 const base::Value* pref_value = NULL; 145 const base::Value* pref_value = NULL;
140 EXPECT_TRUE( 146 EXPECT_TRUE(
141 store_->GetValue(bookmarks::prefs::kManagedBookmarks, &pref_value)); 147 store_->GetValue(bookmarks::prefs::kManagedBookmarks, &pref_value));
142 ASSERT_TRUE(pref_value); 148 ASSERT_TRUE(pref_value);
143 149
144 scoped_ptr<base::Value> expected( 150 scoped_ptr<base::Value> expected(
145 extensions::ListBuilder() 151 extensions::ListBuilder()
146 .Append(extensions::DictionaryBuilder() 152 .Append(extensions::DictionaryBuilder()
147 .Set("name", "Google") 153 .Set("name", "Google")
148 .Set("url", "http://google.com/")) 154 .Set("url", "http://google.com/"))
149 .Build()); 155 .Build());
150 EXPECT_TRUE(pref_value->Equals(expected.get())); 156 EXPECT_TRUE(pref_value->Equals(expected.get()));
151 } 157 }
158 #endif
152 159
160 #if defined(ENABLE_EXTENSIONS)
153 TEST_F(ManagedBookmarksPolicyHandlerTest, BadBookmark) { 161 TEST_F(ManagedBookmarksPolicyHandlerTest, BadBookmark) {
154 PolicyMap policy; 162 PolicyMap policy;
155 policy.Set(key::kManagedBookmarks, 163 policy.Set(key::kManagedBookmarks,
156 POLICY_LEVEL_MANDATORY, 164 POLICY_LEVEL_MANDATORY,
157 POLICY_SCOPE_USER, 165 POLICY_SCOPE_USER,
158 base::JSONReader::Read( 166 base::JSONReader::Read(
159 "[" 167 "["
160 " {" 168 " {"
161 " \"name\": \"Empty\"," 169 " \"name\": \"Empty\","
162 " \"url\": \"\"" 170 " \"url\": \"\""
(...skipping 19 matching lines...) Expand all
182 ASSERT_TRUE(pref_value); 190 ASSERT_TRUE(pref_value);
183 191
184 scoped_ptr<base::Value> expected( 192 scoped_ptr<base::Value> expected(
185 extensions::ListBuilder() 193 extensions::ListBuilder()
186 .Append(extensions::DictionaryBuilder() 194 .Append(extensions::DictionaryBuilder()
187 .Set("name", "Google") 195 .Set("name", "Google")
188 .Set("url", "http://google.com/")) 196 .Set("url", "http://google.com/"))
189 .Build()); 197 .Build());
190 EXPECT_TRUE(pref_value->Equals(expected.get())); 198 EXPECT_TRUE(pref_value->Equals(expected.get()));
191 } 199 }
200 #endif
192 201
193 } // namespace policy 202 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/shortcuts_provider_unittest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698