OLD | NEW |
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/base_feature_provider.h" | 5 #include "chrome/common/extensions/features/base_feature_provider.h" |
6 | 6 |
7 #include "chrome/common/extensions/features/feature_channel.h" | 7 #include "chrome/common/extensions/features/feature_channel.h" |
8 #include "chrome/common/extensions/features/permission_feature.h" | 8 #include "chrome/common/extensions/features/permission_feature.h" |
9 #include "chrome/common/extensions/value_builder.h" | 9 #include "chrome/common/extensions/value_builder.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 139 |
140 // If we remove it, it works. | 140 // If we remove it, it works. |
141 feature2->Remove("contexts", NULL); | 141 feature2->Remove("contexts", NULL); |
142 provider.reset(new BaseFeatureProvider(*value, CreatePermissionFeature)); | 142 provider.reset(new BaseFeatureProvider(*value, CreatePermissionFeature)); |
143 EXPECT_TRUE(provider->GetFeature("feature2")); | 143 EXPECT_TRUE(provider->GetFeature("feature2")); |
144 } | 144 } |
145 | 145 |
146 TEST(BaseFeatureProviderTest, ComplexFeatures) { | 146 TEST(BaseFeatureProviderTest, ComplexFeatures) { |
147 scoped_ptr<base::DictionaryValue> rule( | 147 scoped_ptr<base::DictionaryValue> rule( |
148 DictionaryBuilder() | 148 DictionaryBuilder() |
149 .Set("feature1", | 149 .Set("feature1", ListBuilder() |
150 ListBuilder().Append(DictionaryBuilder() | 150 .Append(DictionaryBuilder() |
151 .Set("channel", "beta") | 151 .Set("channel", "beta") |
152 .Set("extension_types", | 152 .Set("extension_types", ListBuilder() |
153 ListBuilder().Append("extension"))) | 153 .Append("extension"))) |
154 .Append(DictionaryBuilder() | 154 .Append(DictionaryBuilder() |
155 .Set("channel", "beta") | 155 .Set("channel", "beta") |
156 .Set("extension_types", | 156 .Set("extension_types", ListBuilder() |
157 ListBuilder().Append("packaged_app")))) | 157 .Append("legacy_packaged_app")))) |
158 .Build()); | 158 .Build()); |
159 | 159 |
160 scoped_ptr<BaseFeatureProvider> provider( | 160 scoped_ptr<BaseFeatureProvider> provider( |
161 new BaseFeatureProvider(*rule, NULL)); | 161 new BaseFeatureProvider(*rule, NULL)); |
162 | 162 |
163 Feature* feature = provider->GetFeature("feature1"); | 163 Feature* feature = provider->GetFeature("feature1"); |
164 EXPECT_TRUE(feature); | 164 EXPECT_TRUE(feature); |
165 | 165 |
166 // Make sure both rules are applied correctly. | 166 // Make sure both rules are applied correctly. |
167 { | 167 { |
(...skipping 18 matching lines...) Expand all Loading... |
186 Feature::UNSPECIFIED_PLATFORM).result()); | 186 Feature::UNSPECIFIED_PLATFORM).result()); |
187 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( | 187 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( |
188 "2", | 188 "2", |
189 Manifest::TYPE_LEGACY_PACKAGED_APP, | 189 Manifest::TYPE_LEGACY_PACKAGED_APP, |
190 Feature::UNSPECIFIED_LOCATION, | 190 Feature::UNSPECIFIED_LOCATION, |
191 Feature::UNSPECIFIED_PLATFORM).result()); | 191 Feature::UNSPECIFIED_PLATFORM).result()); |
192 } | 192 } |
193 } | 193 } |
194 | 194 |
195 } // namespace extensions | 195 } // namespace extensions |
OLD | NEW |