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

Side by Side Diff: chrome/common/extensions/features/chrome_channel_feature_filter_unittest.cc

Issue 1739183003: Make extensions::DictionaryBuilder and extensions::ListValue unmovable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 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 "chrome/common/extensions/features/chrome_channel_feature_filter.h" 5 #include "chrome/common/extensions/features/chrome_channel_feature_filter.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 provider.reset( 172 provider.reset(
173 new BaseFeatureProvider(*value, CreateFeature<PermissionFeature>)); 173 new BaseFeatureProvider(*value, CreateFeature<PermissionFeature>));
174 EXPECT_TRUE(provider->GetFeature("feature2")); 174 EXPECT_TRUE(provider->GetFeature("feature2"));
175 } 175 }
176 176
177 // Tests simple feature availability across channels. 177 // Tests simple feature availability across channels.
178 TEST_F(ChromeChannelFeatureFilterTest, SimpleFeatureAvailability) { 178 TEST_F(ChromeChannelFeatureFilterTest, SimpleFeatureAvailability) {
179 scoped_ptr<base::DictionaryValue> rule( 179 scoped_ptr<base::DictionaryValue> rule(
180 DictionaryBuilder() 180 DictionaryBuilder()
181 .Set("feature1", 181 .Set("feature1",
182 std::move(ListBuilder() 182 ListBuilder()
183 .Append(std::move( 183 .Append(DictionaryBuilder()
184 DictionaryBuilder() 184 .Set("channel", "beta")
185 .Set("channel", "beta") 185 .Set("extension_types",
186 .Set("extension_types", 186 ListBuilder().Append("extension").Build())
187 std::move(ListBuilder().Append( 187 .Build())
188 "extension"))))) 188 .Append(DictionaryBuilder()
189 .Append(std::move( 189 .Set("channel", "beta")
190 DictionaryBuilder() 190 .Set("extension_types",
191 .Set("channel", "beta") 191 ListBuilder()
192 .Set("extension_types", 192 .Append("legacy_packaged_app")
193 std::move(ListBuilder().Append( 193 .Build())
194 "legacy_packaged_app"))))))) 194 .Build())
195 .Build())
195 .Build()); 196 .Build());
196 197
197 scoped_ptr<BaseFeatureProvider> provider( 198 scoped_ptr<BaseFeatureProvider> provider(
198 new BaseFeatureProvider(*rule, CreateFeature<SimpleFeature>)); 199 new BaseFeatureProvider(*rule, CreateFeature<SimpleFeature>));
199 200
200 Feature* feature = provider->GetFeature("feature1"); 201 Feature* feature = provider->GetFeature("feature1");
201 EXPECT_TRUE(feature); 202 EXPECT_TRUE(feature);
202 203
203 // Make sure both rules are applied correctly. 204 // Make sure both rules are applied correctly.
204 { 205 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // Tests complex feature availability across channels. 237 // Tests complex feature availability across channels.
237 TEST_F(ChromeChannelFeatureFilterTest, ComplexFeatureAvailability) { 238 TEST_F(ChromeChannelFeatureFilterTest, ComplexFeatureAvailability) {
238 scoped_ptr<ComplexFeature::FeatureList> features( 239 scoped_ptr<ComplexFeature::FeatureList> features(
239 new ComplexFeature::FeatureList()); 240 new ComplexFeature::FeatureList());
240 241
241 // Rule: "extension", channel trunk. 242 // Rule: "extension", channel trunk.
242 scoped_ptr<SimpleFeature> simple_feature(CreateFeature<SimpleFeature>()); 243 scoped_ptr<SimpleFeature> simple_feature(CreateFeature<SimpleFeature>());
243 scoped_ptr<base::DictionaryValue> rule( 244 scoped_ptr<base::DictionaryValue> rule(
244 DictionaryBuilder() 245 DictionaryBuilder()
245 .Set("channel", "trunk") 246 .Set("channel", "trunk")
246 .Set("extension_types", std::move(ListBuilder().Append("extension"))) 247 .Set("extension_types", ListBuilder().Append("extension").Build())
247 .Build()); 248 .Build());
248 simple_feature->Parse(rule.get()); 249 simple_feature->Parse(rule.get());
249 features->push_back(std::move(simple_feature)); 250 features->push_back(std::move(simple_feature));
250 251
251 // Rule: "legacy_packaged_app", channel stable. 252 // Rule: "legacy_packaged_app", channel stable.
252 simple_feature.reset(CreateFeature<SimpleFeature>()); 253 simple_feature.reset(CreateFeature<SimpleFeature>());
253 rule = DictionaryBuilder() 254 rule = DictionaryBuilder()
254 .Set("channel", "stable") 255 .Set("channel", "stable")
255 .Set("extension_types", 256 .Set("extension_types",
256 std::move(ListBuilder().Append("legacy_packaged_app"))) 257 ListBuilder().Append("legacy_packaged_app").Build())
257 .Build(); 258 .Build();
258 simple_feature->Parse(rule.get()); 259 simple_feature->Parse(rule.get());
259 features->push_back(std::move(simple_feature)); 260 features->push_back(std::move(simple_feature));
260 261
261 scoped_ptr<ComplexFeature> feature(new ComplexFeature(std::move(features))); 262 scoped_ptr<ComplexFeature> feature(new ComplexFeature(std::move(features)));
262 263
263 // Test match 1st rule. 264 // Test match 1st rule.
264 { 265 {
265 ScopedCurrentChannel current_channel(version_info::Channel::UNKNOWN); 266 ScopedCurrentChannel current_channel(version_info::Channel::UNKNOWN);
266 EXPECT_EQ( 267 EXPECT_EQ(
(...skipping 24 matching lines...) Expand all
291 Feature::IS_AVAILABLE, 292 Feature::IS_AVAILABLE,
292 feature->IsAvailableToManifest("1", 293 feature->IsAvailableToManifest("1",
293 Manifest::TYPE_EXTENSION, 294 Manifest::TYPE_EXTENSION,
294 Manifest::INVALID_LOCATION, 295 Manifest::INVALID_LOCATION,
295 Feature::UNSPECIFIED_PLATFORM, 296 Feature::UNSPECIFIED_PLATFORM,
296 Feature::GetCurrentPlatform()).result()); 297 Feature::GetCurrentPlatform()).result());
297 } 298 }
298 } 299 }
299 300
300 } // namespace extensions 301 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698