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

Side by Side Diff: extensions/common/features/complex_feature_unittest.cc

Issue 1152183002: Subsituting pattern ScopedVector push_back.(ptr.release()) with push_back(ptr.Pass()) in extensions… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 "extensions/common/features/complex_feature.h" 5 #include "extensions/common/features/complex_feature.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "extensions/common/features/simple_feature.h" 9 #include "extensions/common/features/simple_feature.h"
10 #include "extensions/common/manifest.h" 10 #include "extensions/common/manifest.h"
11 #include "extensions/common/value_builder.h" 11 #include "extensions/common/value_builder.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace extensions { 14 namespace extensions {
15 15
16 TEST(ComplexFeatureTest, MultipleRulesWhitelist) { 16 TEST(ComplexFeatureTest, MultipleRulesWhitelist) {
17 const std::string kIdFoo("fooabbbbccccddddeeeeffffgggghhhh"); 17 const std::string kIdFoo("fooabbbbccccddddeeeeffffgggghhhh");
18 const std::string kIdBar("barabbbbccccddddeeeeffffgggghhhh"); 18 const std::string kIdBar("barabbbbccccddddeeeeffffgggghhhh");
19 scoped_ptr<ComplexFeature::FeatureList> features( 19 scoped_ptr<ComplexFeature::FeatureList> features(
20 new ComplexFeature::FeatureList()); 20 new ComplexFeature::FeatureList());
21 21
22 // Rule: "extension", whitelist "foo". 22 // Rule: "extension", whitelist "foo".
23 scoped_ptr<SimpleFeature> simple_feature(new SimpleFeature); 23 scoped_ptr<SimpleFeature> simple_feature(new SimpleFeature);
24 scoped_ptr<base::DictionaryValue> rule( 24 scoped_ptr<base::DictionaryValue> rule(
25 DictionaryBuilder() 25 DictionaryBuilder()
26 .Set("whitelist", ListBuilder().Append(kIdFoo)) 26 .Set("whitelist", ListBuilder().Append(kIdFoo))
27 .Set("extension_types", ListBuilder() 27 .Set("extension_types", ListBuilder()
28 .Append("extension")).Build()); 28 .Append("extension")).Build());
29 simple_feature->Parse(rule.get()); 29 simple_feature->Parse(rule.get());
30 features->push_back(simple_feature.release()); 30 features->push_back(simple_feature.Pass());
31 31
32 // Rule: "legacy_packaged_app", whitelist "bar". 32 // Rule: "legacy_packaged_app", whitelist "bar".
33 simple_feature.reset(new SimpleFeature); 33 simple_feature.reset(new SimpleFeature);
34 rule = DictionaryBuilder() 34 rule = DictionaryBuilder()
35 .Set("whitelist", ListBuilder().Append(kIdBar)) 35 .Set("whitelist", ListBuilder().Append(kIdBar))
36 .Set("extension_types", ListBuilder() 36 .Set("extension_types", ListBuilder()
37 .Append("legacy_packaged_app")).Build(); 37 .Append("legacy_packaged_app")).Build();
38 simple_feature->Parse(rule.get()); 38 simple_feature->Parse(rule.get());
39 features->push_back(simple_feature.release()); 39 features->push_back(simple_feature.Pass());
40 40
41 scoped_ptr<ComplexFeature> feature(new ComplexFeature(features.Pass())); 41 scoped_ptr<ComplexFeature> feature(new ComplexFeature(features.Pass()));
42 42
43 // Test match 1st rule. 43 // Test match 1st rule.
44 EXPECT_EQ( 44 EXPECT_EQ(
45 Feature::IS_AVAILABLE, 45 Feature::IS_AVAILABLE,
46 feature->IsAvailableToManifest(kIdFoo, 46 feature->IsAvailableToManifest(kIdFoo,
47 Manifest::TYPE_EXTENSION, 47 Manifest::TYPE_EXTENSION,
48 Manifest::INVALID_LOCATION, 48 Manifest::INVALID_LOCATION,
49 Feature::UNSPECIFIED_PLATFORM, 49 Feature::UNSPECIFIED_PLATFORM,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 new ComplexFeature::FeatureList()); 81 new ComplexFeature::FeatureList());
82 82
83 // Rule which depends on an extension-only feature (content_security_policy). 83 // Rule which depends on an extension-only feature (content_security_policy).
84 scoped_ptr<SimpleFeature> simple_feature(new SimpleFeature); 84 scoped_ptr<SimpleFeature> simple_feature(new SimpleFeature);
85 scoped_ptr<base::DictionaryValue> rule = 85 scoped_ptr<base::DictionaryValue> rule =
86 DictionaryBuilder() 86 DictionaryBuilder()
87 .Set("dependencies", 87 .Set("dependencies",
88 ListBuilder().Append("manifest:content_security_policy")) 88 ListBuilder().Append("manifest:content_security_policy"))
89 .Build(); 89 .Build();
90 simple_feature->Parse(rule.get()); 90 simple_feature->Parse(rule.get());
91 features->push_back(simple_feature.release()); 91 features->push_back(simple_feature.Pass());
92 92
93 // Rule which depends on an platform-app-only feature (serial). 93 // Rule which depends on an platform-app-only feature (serial).
94 simple_feature.reset(new SimpleFeature); 94 simple_feature.reset(new SimpleFeature);
95 rule = DictionaryBuilder() 95 rule = DictionaryBuilder()
96 .Set("dependencies", ListBuilder().Append("permission:serial")) 96 .Set("dependencies", ListBuilder().Append("permission:serial"))
97 .Build(); 97 .Build();
98 simple_feature->Parse(rule.get()); 98 simple_feature->Parse(rule.get());
99 features->push_back(simple_feature.release()); 99 features->push_back(simple_feature.Pass());
100 100
101 scoped_ptr<ComplexFeature> feature(new ComplexFeature(features.Pass())); 101 scoped_ptr<ComplexFeature> feature(new ComplexFeature(features.Pass()));
102 102
103 // Available to extensions because of the content_security_policy rule. 103 // Available to extensions because of the content_security_policy rule.
104 EXPECT_EQ( 104 EXPECT_EQ(
105 Feature::IS_AVAILABLE, 105 Feature::IS_AVAILABLE,
106 feature->IsAvailableToManifest("extensionid", 106 feature->IsAvailableToManifest("extensionid",
107 Manifest::TYPE_EXTENSION, 107 Manifest::TYPE_EXTENSION,
108 Manifest::INVALID_LOCATION, 108 Manifest::INVALID_LOCATION,
109 Feature::UNSPECIFIED_PLATFORM, 109 Feature::UNSPECIFIED_PLATFORM,
(...skipping 12 matching lines...) Expand all
122 EXPECT_EQ( 122 EXPECT_EQ(
123 Feature::INVALID_TYPE, 123 Feature::INVALID_TYPE,
124 feature->IsAvailableToManifest("hostedappid", 124 feature->IsAvailableToManifest("hostedappid",
125 Manifest::TYPE_HOSTED_APP, 125 Manifest::TYPE_HOSTED_APP,
126 Manifest::INVALID_LOCATION, 126 Manifest::INVALID_LOCATION,
127 Feature::UNSPECIFIED_PLATFORM, 127 Feature::UNSPECIFIED_PLATFORM,
128 Feature::GetCurrentPlatform()).result()); 128 Feature::GetCurrentPlatform()).result());
129 } 129 }
130 130
131 } // namespace extensions 131 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/features/base_feature_provider.cc ('k') | extensions/common/features/simple_feature.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698