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

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

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 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/simple_feature.h" 7 #include "chrome/common/extensions/features/simple_feature.h"
8 #include "chrome/common/extensions/value_builder.h" 8 #include "chrome/common/extensions/value_builder.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 using chrome::VersionInfo; 11 using chrome::VersionInfo;
12 using extensions::ComplexFeature; 12 using extensions::ComplexFeature;
13 using extensions::DictionaryBuilder; 13 using extensions::DictionaryBuilder;
14 using extensions::Extension;
15 using extensions::Feature; 14 using extensions::Feature;
16 using extensions::ListBuilder; 15 using extensions::ListBuilder;
16 using extensions::Manifest;
17 using extensions::SimpleFeature; 17 using extensions::SimpleFeature;
18 18
19 namespace { 19 namespace {
20 20
21 class ExtensionComplexFeatureTest : public testing::Test { 21 class ExtensionComplexFeatureTest : public testing::Test {
22 protected: 22 protected:
23 ExtensionComplexFeatureTest() 23 ExtensionComplexFeatureTest()
24 : current_channel_(VersionInfo::CHANNEL_UNKNOWN) {} 24 : current_channel_(VersionInfo::CHANNEL_UNKNOWN) {}
25 virtual ~ExtensionComplexFeatureTest() {} 25 virtual ~ExtensionComplexFeatureTest() {}
26 26
(...skipping 20 matching lines...) Expand all
47 .Set("whitelist", ListBuilder().Append("bar")) 47 .Set("whitelist", ListBuilder().Append("bar"))
48 .Set("extension_types", ListBuilder().Append("packaged_app")).Build(); 48 .Set("extension_types", ListBuilder().Append("packaged_app")).Build();
49 simple_feature->Parse(rule.get()); 49 simple_feature->Parse(rule.get());
50 features->push_back(simple_feature.release()); 50 features->push_back(simple_feature.release());
51 51
52 scoped_ptr<ComplexFeature> feature(new ComplexFeature(features.Pass())); 52 scoped_ptr<ComplexFeature> feature(new ComplexFeature(features.Pass()));
53 53
54 // Test match 1st rule. 54 // Test match 1st rule.
55 EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( 55 EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest(
56 "foo", 56 "foo",
57 Extension::TYPE_EXTENSION, 57 Manifest::TYPE_EXTENSION,
58 Feature::UNSPECIFIED_LOCATION, 58 Feature::UNSPECIFIED_LOCATION,
59 Feature::UNSPECIFIED_PLATFORM, 59 Feature::UNSPECIFIED_PLATFORM,
60 Feature::GetCurrentPlatform()).result()); 60 Feature::GetCurrentPlatform()).result());
61 61
62 // Test match 2nd rule. 62 // Test match 2nd rule.
63 EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( 63 EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest(
64 "bar", 64 "bar",
65 Extension::TYPE_LEGACY_PACKAGED_APP, 65 Manifest::TYPE_LEGACY_PACKAGED_APP,
66 Feature::UNSPECIFIED_LOCATION, 66 Feature::UNSPECIFIED_LOCATION,
67 Feature::UNSPECIFIED_PLATFORM, 67 Feature::UNSPECIFIED_PLATFORM,
68 Feature::GetCurrentPlatform()).result()); 68 Feature::GetCurrentPlatform()).result());
69 69
70 // Test whitelist with wrong extension type. 70 // Test whitelist with wrong extension type.
71 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( 71 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest(
72 "bar", 72 "bar",
73 Extension::TYPE_EXTENSION, 73 Manifest::TYPE_EXTENSION,
74 Feature::UNSPECIFIED_LOCATION, 74 Feature::UNSPECIFIED_LOCATION,
75 Feature::UNSPECIFIED_PLATFORM, 75 Feature::UNSPECIFIED_PLATFORM,
76 Feature::GetCurrentPlatform()).result()); 76 Feature::GetCurrentPlatform()).result());
77 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( 77 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest(
78 "foo", 78 "foo",
79 Extension::TYPE_LEGACY_PACKAGED_APP, 79 Manifest::TYPE_LEGACY_PACKAGED_APP,
80 Feature::UNSPECIFIED_LOCATION, 80 Feature::UNSPECIFIED_LOCATION,
81 Feature::UNSPECIFIED_PLATFORM, 81 Feature::UNSPECIFIED_PLATFORM,
82 Feature::GetCurrentPlatform()).result()); 82 Feature::GetCurrentPlatform()).result());
83 } 83 }
84 84
85 TEST_F(ExtensionComplexFeatureTest, MultipleRulesChannels) { 85 TEST_F(ExtensionComplexFeatureTest, MultipleRulesChannels) {
86 scoped_ptr<ComplexFeature::FeatureList> features( 86 scoped_ptr<ComplexFeature::FeatureList> features(
87 new ComplexFeature::FeatureList()); 87 new ComplexFeature::FeatureList());
88 88
89 // Rule: "extension", channel trunk. 89 // Rule: "extension", channel trunk.
(...skipping 13 matching lines...) Expand all
103 simple_feature->Parse(rule.get()); 103 simple_feature->Parse(rule.get());
104 features->push_back(simple_feature.release()); 104 features->push_back(simple_feature.release());
105 105
106 scoped_ptr<ComplexFeature> feature(new ComplexFeature(features.Pass())); 106 scoped_ptr<ComplexFeature> feature(new ComplexFeature(features.Pass()));
107 107
108 // Test match 1st rule. 108 // Test match 1st rule.
109 { 109 {
110 Feature::ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_UNKNOWN); 110 Feature::ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_UNKNOWN);
111 EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( 111 EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest(
112 "1", 112 "1",
113 Extension::TYPE_EXTENSION, 113 Manifest::TYPE_EXTENSION,
114 Feature::UNSPECIFIED_LOCATION, 114 Feature::UNSPECIFIED_LOCATION,
115 Feature::UNSPECIFIED_PLATFORM, 115 Feature::UNSPECIFIED_PLATFORM,
116 Feature::GetCurrentPlatform()).result()); 116 Feature::GetCurrentPlatform()).result());
117 } 117 }
118 118
119 // Test match 2nd rule. 119 // Test match 2nd rule.
120 { 120 {
121 Feature::ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_BETA); 121 Feature::ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_BETA);
122 EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( 122 EXPECT_EQ(Feature::IS_AVAILABLE, feature->IsAvailableToManifest(
123 "2", 123 "2",
124 Extension::TYPE_LEGACY_PACKAGED_APP, 124 Manifest::TYPE_LEGACY_PACKAGED_APP,
125 Feature::UNSPECIFIED_LOCATION, 125 Feature::UNSPECIFIED_LOCATION,
126 Feature::UNSPECIFIED_PLATFORM, 126 Feature::UNSPECIFIED_PLATFORM,
127 Feature::GetCurrentPlatform()).result()); 127 Feature::GetCurrentPlatform()).result());
128 } 128 }
129 129
130 // Test feature not available to extensions above channel unknown. 130 // Test feature not available to extensions above channel unknown.
131 { 131 {
132 Feature::ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_BETA); 132 Feature::ScopedCurrentChannel current_channel(VersionInfo::CHANNEL_BETA);
133 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( 133 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest(
134 "1", 134 "1",
135 Extension::TYPE_EXTENSION, 135 Manifest::TYPE_EXTENSION,
136 Feature::UNSPECIFIED_LOCATION, 136 Feature::UNSPECIFIED_LOCATION,
137 Feature::UNSPECIFIED_PLATFORM, 137 Feature::UNSPECIFIED_PLATFORM,
138 Feature::GetCurrentPlatform()).result()); 138 Feature::GetCurrentPlatform()).result());
139 } 139 }
140 } 140 }
141 141
142 } // namespace 142 } // namespace
OLDNEW
« no previous file with comments | « chrome/common/extensions/features/complex_feature.cc ('k') | chrome/common/extensions/features/feature.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698