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

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

Issue 22299009: Move channel-related (Chrome-specific) global state out of Feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/complex_feature.h" 5 #include "chrome/common/extensions/features/complex_feature.h"
6 6
7 #include "chrome/common/extensions/features/feature_channel.h"
7 #include "chrome/common/extensions/features/simple_feature.h" 8 #include "chrome/common/extensions/features/simple_feature.h"
8 #include "chrome/common/extensions/value_builder.h" 9 #include "chrome/common/extensions/value_builder.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 using chrome::VersionInfo; 12 using chrome::VersionInfo;
12 using extensions::ComplexFeature; 13 using extensions::ComplexFeature;
13 using extensions::DictionaryBuilder; 14 using extensions::DictionaryBuilder;
14 using extensions::Feature; 15 using extensions::Feature;
15 using extensions::ListBuilder; 16 using extensions::ListBuilder;
16 using extensions::Manifest; 17 using extensions::Manifest;
18 using extensions::ScopedCurrentChannel;
17 using extensions::SimpleFeature; 19 using extensions::SimpleFeature;
18 20
19 namespace { 21 namespace {
20 22
21 class ExtensionComplexFeatureTest : public testing::Test { 23 class ExtensionComplexFeatureTest : public testing::Test {
22 protected: 24 protected:
23 ExtensionComplexFeatureTest() 25 ExtensionComplexFeatureTest()
24 : current_channel_(VersionInfo::CHANNEL_UNKNOWN) {} 26 : current_channel_(VersionInfo::CHANNEL_UNKNOWN) {}
25 virtual ~ExtensionComplexFeatureTest() {} 27 virtual ~ExtensionComplexFeatureTest() {}
26 28
27 private: 29 private:
28 Feature::ScopedCurrentChannel current_channel_; 30 ScopedCurrentChannel current_channel_;
29 }; 31 };
30 32
31 TEST_F(ExtensionComplexFeatureTest, MultipleRulesWhitelist) { 33 TEST_F(ExtensionComplexFeatureTest, MultipleRulesWhitelist) {
32 const std::string kIdFoo("fooabbbbccccddddeeeeffffgggghhhh"); 34 const std::string kIdFoo("fooabbbbccccddddeeeeffffgggghhhh");
33 const std::string kIdBar("barabbbbccccddddeeeeffffgggghhhh"); 35 const std::string kIdBar("barabbbbccccddddeeeeffffgggghhhh");
34 scoped_ptr<ComplexFeature::FeatureList> features( 36 scoped_ptr<ComplexFeature::FeatureList> features(
35 new ComplexFeature::FeatureList()); 37 new ComplexFeature::FeatureList());
36 38
37 // Rule: "extension", whitelist "foo". 39 // Rule: "extension", whitelist "foo".
38 scoped_ptr<SimpleFeature> simple_feature(new SimpleFeature()); 40 scoped_ptr<SimpleFeature> simple_feature(new SimpleFeature());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 rule = DictionaryBuilder() 103 rule = DictionaryBuilder()
102 .Set("channel", "stable") 104 .Set("channel", "stable")
103 .Set("extension_types", ListBuilder().Append("packaged_app")).Build(); 105 .Set("extension_types", ListBuilder().Append("packaged_app")).Build();
104 simple_feature->Parse(rule.get()); 106 simple_feature->Parse(rule.get());
105 features->push_back(simple_feature.release()); 107 features->push_back(simple_feature.release());
106 108
107 scoped_ptr<ComplexFeature> feature(new ComplexFeature(features.Pass())); 109 scoped_ptr<ComplexFeature> feature(new ComplexFeature(features.Pass()));
108 110
109 // Test match 1st rule. 111 // Test match 1st rule.
110 { 112 {
111 Feature::ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_UNKNOWN); 113 ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_UNKNOWN);
112 EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( 114 EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest(
113 "1", 115 "1",
114 Manifest::TYPE_EXTENSION, 116 Manifest::TYPE_EXTENSION,
115 Feature::UNSPECIFIED_LOCATION, 117 Feature::UNSPECIFIED_LOCATION,
116 Feature::UNSPECIFIED_PLATFORM, 118 Feature::UNSPECIFIED_PLATFORM,
117 Feature::GetCurrentPlatform()).result()); 119 Feature::GetCurrentPlatform()).result());
118 } 120 }
119 121
120 // Test match 2nd rule. 122 // Test match 2nd rule.
121 { 123 {
122 Feature::ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_BETA); 124 ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_BETA);
123 EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( 125 EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest(
124 "2", 126 "2",
125 Manifest::TYPE_LEGACY_PACKAGED_APP, 127 Manifest::TYPE_LEGACY_PACKAGED_APP,
126 Feature::UNSPECIFIED_LOCATION, 128 Feature::UNSPECIFIED_LOCATION,
127 Feature::UNSPECIFIED_PLATFORM, 129 Feature::UNSPECIFIED_PLATFORM,
128 Feature::GetCurrentPlatform()).result()); 130 Feature::GetCurrentPlatform()).result());
129 } 131 }
130 132
131 // Test feature not available to extensions above channel unknown. 133 // Test feature not available to extensions above channel unknown.
132 { 134 {
133 Feature::ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_BETA); 135 ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_BETA);
134 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( 136 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest(
135 "1", 137 "1",
136 Manifest::TYPE_EXTENSION, 138 Manifest::TYPE_EXTENSION,
137 Feature::UNSPECIFIED_LOCATION, 139 Feature::UNSPECIFIED_LOCATION,
138 Feature::UNSPECIFIED_PLATFORM, 140 Feature::UNSPECIFIED_PLATFORM,
139 Feature::GetCurrentPlatform()).result()); 141 Feature::GetCurrentPlatform()).result());
140 } 142 }
141 } 143 }
142 144
143 } // namespace 145 } // namespace
OLDNEW
« no previous file with comments | « chrome/common/extensions/features/base_feature_provider_unittest.cc ('k') | chrome/common/extensions/features/feature.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698