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

Unified Diff: extensions/common/features/simple_feature_unittest.cc

Issue 2705513002: Extensions: Only create Web request rules registry if Declarative Web Request is enabled. (Closed)
Patch Set: Correct comment. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/common/features/simple_feature.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/features/simple_feature_unittest.cc
diff --git a/extensions/common/features/simple_feature_unittest.cc b/extensions/common/features/simple_feature_unittest.cc
index a570248922170a3db7529953129d3533e75aa1ae..e8f4c3c9da6379a12b9b23b27bbc1b4a1fe207dc 100644
--- a/extensions/common/features/simple_feature_unittest.cc
+++ b/extensions/common/features/simple_feature_unittest.cc
@@ -45,15 +45,9 @@ struct FeatureSessionTypeTestData {
Feature::AvailabilityResult IsAvailableInChannel(Channel channel_for_feature,
Channel channel_for_testing) {
- ScopedCurrentChannel current_channel(channel_for_testing);
-
SimpleFeature feature;
feature.set_channel(channel_for_feature);
- return feature
- .IsAvailableToManifest("random-extension", Manifest::TYPE_UNKNOWN,
- Manifest::INVALID_LOCATION, -1,
- Feature::GetCurrentPlatform())
- .result();
+ return feature.IsAvailableToChannel(channel_for_testing).result();
}
} // namespace
@@ -762,56 +756,6 @@ TEST_F(SimpleFeatureTest, SupportedChannel) {
IsAvailableInChannel(Channel::UNKNOWN, Channel::STABLE));
}
-// Tests simple feature availability across channels.
-TEST_F(SimpleFeatureTest, SimpleFeatureAvailability) {
- std::unique_ptr<ComplexFeature> complex_feature;
- {
- std::unique_ptr<SimpleFeature> feature1(new SimpleFeature());
- feature1->channel_.reset(new Channel(Channel::BETA));
- feature1->extension_types_.push_back(Manifest::TYPE_EXTENSION);
- std::unique_ptr<SimpleFeature> feature2(new SimpleFeature());
- feature2->channel_.reset(new Channel(Channel::BETA));
- feature2->extension_types_.push_back(Manifest::TYPE_LEGACY_PACKAGED_APP);
- std::vector<Feature*> list;
- list.push_back(feature1.release());
- list.push_back(feature2.release());
- complex_feature.reset(new ComplexFeature(&list));
- }
-
- Feature* feature = static_cast<Feature*>(complex_feature.get());
- // Make sure both rules are applied correctly.
- {
- ScopedCurrentChannel current_channel(Channel::BETA);
- EXPECT_EQ(
- Feature::IS_AVAILABLE,
- feature->IsAvailableToManifest("1",
- Manifest::TYPE_EXTENSION,
- Manifest::INVALID_LOCATION,
- Feature::UNSPECIFIED_PLATFORM).result());
- EXPECT_EQ(
- Feature::IS_AVAILABLE,
- feature->IsAvailableToManifest("2",
- Manifest::TYPE_LEGACY_PACKAGED_APP,
- Manifest::INVALID_LOCATION,
- Feature::UNSPECIFIED_PLATFORM).result());
- }
- {
- ScopedCurrentChannel current_channel(Channel::STABLE);
- EXPECT_NE(
- Feature::IS_AVAILABLE,
- feature->IsAvailableToManifest("1",
- Manifest::TYPE_EXTENSION,
- Manifest::INVALID_LOCATION,
- Feature::UNSPECIFIED_PLATFORM).result());
- EXPECT_NE(
- Feature::IS_AVAILABLE,
- feature->IsAvailableToManifest("2",
- Manifest::TYPE_LEGACY_PACKAGED_APP,
- Manifest::INVALID_LOCATION,
- Feature::UNSPECIFIED_PLATFORM).result());
- }
-}
-
// Tests complex feature availability across channels.
TEST_F(SimpleFeatureTest, ComplexFeatureAvailability) {
std::unique_ptr<ComplexFeature> complex_feature;
@@ -821,8 +765,8 @@ TEST_F(SimpleFeatureTest, ComplexFeatureAvailability) {
feature1->channel_.reset(new Channel(Channel::UNKNOWN));
feature1->extension_types_.push_back(Manifest::TYPE_EXTENSION);
std::unique_ptr<SimpleFeature> feature2(new SimpleFeature());
- // Rule: "legacy_packaged_app", channel stable.
- feature2->channel_.reset(new Channel(Channel::STABLE));
+ // Rule: "legacy_packaged_app", channel beta.
+ feature2->channel_.reset(new Channel(Channel::BETA));
feature2->extension_types_.push_back(Manifest::TYPE_LEGACY_PACKAGED_APP);
std::vector<Feature*> list;
list.push_back(feature1.release());
@@ -830,7 +774,18 @@ TEST_F(SimpleFeatureTest, ComplexFeatureAvailability) {
complex_feature.reset(new ComplexFeature(&list));
}
- Feature* feature = static_cast<Feature*>(complex_feature.get());
+ Feature* feature = complex_feature.get();
+ EXPECT_EQ(Feature::IS_AVAILABLE,
+ feature->IsAvailableToChannel(Channel::UNKNOWN).result());
+ EXPECT_EQ(Feature::IS_AVAILABLE,
+ feature->IsAvailableToChannel(Channel::CANARY).result());
+ EXPECT_EQ(Feature::IS_AVAILABLE,
+ feature->IsAvailableToChannel(Channel::DEV).result());
+ EXPECT_EQ(Feature::IS_AVAILABLE,
+ feature->IsAvailableToChannel(Channel::BETA).result());
+ EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL,
+ feature->IsAvailableToChannel(Channel::STABLE).result());
+
{
ScopedCurrentChannel current_channel(Channel::UNKNOWN);
EXPECT_EQ(Feature::IS_AVAILABLE,
@@ -839,6 +794,12 @@ TEST_F(SimpleFeatureTest, ComplexFeatureAvailability) {
Manifest::INVALID_LOCATION,
Feature::UNSPECIFIED_PLATFORM)
.result());
+ EXPECT_EQ(Feature::IS_AVAILABLE,
+ feature
+ ->IsAvailableToManifest(
+ "1", Manifest::TYPE_LEGACY_PACKAGED_APP,
+ Manifest::INVALID_LOCATION, Feature::UNSPECIFIED_PLATFORM)
+ .result());
}
{
ScopedCurrentChannel current_channel(Channel::BETA);
@@ -848,9 +809,21 @@ TEST_F(SimpleFeatureTest, ComplexFeatureAvailability) {
"2", Manifest::TYPE_LEGACY_PACKAGED_APP,
Manifest::INVALID_LOCATION, Feature::UNSPECIFIED_PLATFORM)
.result());
+ EXPECT_NE(Feature::IS_AVAILABLE,
+ feature
+ ->IsAvailableToManifest("1", Manifest::TYPE_EXTENSION,
+ Manifest::INVALID_LOCATION,
+ Feature::UNSPECIFIED_PLATFORM)
+ .result());
}
{
- ScopedCurrentChannel current_channel(Channel::BETA);
+ ScopedCurrentChannel current_channel(Channel::STABLE);
+ EXPECT_NE(Feature::IS_AVAILABLE,
+ feature
+ ->IsAvailableToManifest(
+ "2", Manifest::TYPE_LEGACY_PACKAGED_APP,
+ Manifest::INVALID_LOCATION, Feature::UNSPECIFIED_PLATFORM)
+ .result());
EXPECT_NE(Feature::IS_AVAILABLE,
feature
->IsAvailableToManifest("1", Manifest::TYPE_EXTENSION,
« no previous file with comments | « extensions/common/features/simple_feature.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698