| OLD | NEW |
| 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/simple_feature.h" | 5 #include "extensions/common/features/simple_feature.h" |
| 6 | 6 |
| 7 #include "chrome/common/extensions/features/chrome_channel_feature_filter.h" | 7 #include "chrome/common/extensions/features/chrome_channel_feature_filter.h" |
| 8 #include "chrome/common/extensions/features/feature_channel.h" | 8 #include "chrome/common/extensions/features/feature_channel.h" |
| 9 #include "extensions/common/value_builder.h" | 9 #include "extensions/common/value_builder.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 using chrome::VersionInfo; | 12 using chrome::VersionInfo; |
| 13 using extensions::DictionaryBuilder; | 13 using extensions::DictionaryBuilder; |
| 14 using extensions::Extension; | 14 using extensions::Extension; |
| 15 using extensions::Feature; | 15 using extensions::Feature; |
| 16 using extensions::ListBuilder; | 16 using extensions::ListBuilder; |
| 17 using extensions::Manifest; | 17 using extensions::Manifest; |
| 18 using extensions::ScopedCurrentChannel; | 18 using extensions::ScopedCurrentChannel; |
| 19 using extensions::SimpleFeature; | 19 using extensions::SimpleFeature; |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 struct IsAvailableTestData { | 23 struct IsAvailableTestData { |
| 24 std::string extension_id; | 24 std::string extension_id; |
| 25 Manifest::Type extension_type; | 25 Manifest::Type extension_type; |
| 26 Feature::Location location; | 26 Manifest::Location location; |
| 27 Feature::Platform platform; | 27 Feature::Platform platform; |
| 28 int manifest_version; | 28 int manifest_version; |
| 29 Feature::AvailabilityResult expected_result; | 29 Feature::AvailabilityResult expected_result; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 template <typename T> |
| 33 std::set<T> Set(const T& t) { |
| 34 std::set<T> set; |
| 35 set.insert(t); |
| 36 return set; |
| 37 } |
| 38 template <typename T> |
| 39 std::set<T> Set(const T& t1, const T& t2) { |
| 40 std::set<T> set = Set(t1); |
| 41 set.insert(t2); |
| 42 return set; |
| 43 } |
| 44 |
| 32 class ExtensionSimpleFeatureTest : public testing::Test { | 45 class ExtensionSimpleFeatureTest : public testing::Test { |
| 33 protected: | 46 protected: |
| 34 ExtensionSimpleFeatureTest() | 47 ExtensionSimpleFeatureTest() |
| 35 : current_channel_(VersionInfo::CHANNEL_UNKNOWN) {} | 48 : current_channel_(VersionInfo::CHANNEL_UNKNOWN) {} |
| 36 virtual ~ExtensionSimpleFeatureTest() {} | 49 virtual ~ExtensionSimpleFeatureTest() {} |
| 37 | 50 |
| 38 private: | 51 private: |
| 39 ScopedCurrentChannel current_channel_; | 52 ScopedCurrentChannel current_channel_; |
| 40 }; | 53 }; |
| 41 | 54 |
| 42 TEST_F(ExtensionSimpleFeatureTest, IsAvailableNullCase) { | 55 TEST_F(ExtensionSimpleFeatureTest, IsAvailableNullCase) { |
| 43 const IsAvailableTestData tests[] = { | 56 const IsAvailableTestData tests[] = { |
| 44 { "", Manifest::TYPE_UNKNOWN, | 57 {"", Manifest::TYPE_UNKNOWN, Manifest::INVALID_LOCATION, |
| 45 Feature::UNSPECIFIED_LOCATION, Feature::UNSPECIFIED_PLATFORM, -1, | 58 Feature::UNSPECIFIED_PLATFORM, -1, Feature::IS_AVAILABLE}, |
| 46 Feature::IS_AVAILABLE }, | 59 {"random-extension", Manifest::TYPE_UNKNOWN, Manifest::INVALID_LOCATION, |
| 47 { "random-extension", Manifest::TYPE_UNKNOWN, | 60 Feature::UNSPECIFIED_PLATFORM, -1, Feature::IS_AVAILABLE}, |
| 48 Feature::UNSPECIFIED_LOCATION, Feature::UNSPECIFIED_PLATFORM, -1, | 61 {"", Manifest::TYPE_LEGACY_PACKAGED_APP, Manifest::INVALID_LOCATION, |
| 49 Feature::IS_AVAILABLE }, | 62 Feature::UNSPECIFIED_PLATFORM, -1, Feature::IS_AVAILABLE}, |
| 50 { "", Manifest::TYPE_LEGACY_PACKAGED_APP, | 63 {"", Manifest::TYPE_UNKNOWN, Manifest::INVALID_LOCATION, |
| 51 Feature::UNSPECIFIED_LOCATION, Feature::UNSPECIFIED_PLATFORM, -1, | 64 Feature::UNSPECIFIED_PLATFORM, -1, Feature::IS_AVAILABLE}, |
| 52 Feature::IS_AVAILABLE }, | 65 {"", Manifest::TYPE_UNKNOWN, Manifest::COMPONENT, |
| 53 { "", Manifest::TYPE_UNKNOWN, | 66 Feature::UNSPECIFIED_PLATFORM, -1, Feature::IS_AVAILABLE}, |
| 54 Feature::UNSPECIFIED_LOCATION, Feature::UNSPECIFIED_PLATFORM, -1, | 67 {"", Manifest::TYPE_UNKNOWN, Manifest::INVALID_LOCATION, |
| 55 Feature::IS_AVAILABLE }, | 68 Feature::CHROMEOS_PLATFORM, -1, Feature::IS_AVAILABLE}, |
| 56 { "", Manifest::TYPE_UNKNOWN, | 69 {"", Manifest::TYPE_UNKNOWN, Manifest::INVALID_LOCATION, |
| 57 Feature::COMPONENT_LOCATION, Feature::UNSPECIFIED_PLATFORM, -1, | 70 Feature::UNSPECIFIED_PLATFORM, 25, Feature::IS_AVAILABLE}}; |
| 58 Feature::IS_AVAILABLE }, | |
| 59 { "", Manifest::TYPE_UNKNOWN, | |
| 60 Feature::UNSPECIFIED_LOCATION, Feature::CHROMEOS_PLATFORM, -1, | |
| 61 Feature::IS_AVAILABLE }, | |
| 62 { "", Manifest::TYPE_UNKNOWN, | |
| 63 Feature::UNSPECIFIED_LOCATION, Feature::UNSPECIFIED_PLATFORM, 25, | |
| 64 Feature::IS_AVAILABLE } | |
| 65 }; | |
| 66 | 71 |
| 67 SimpleFeature feature; | 72 SimpleFeature feature; |
| 68 for (size_t i = 0; i < arraysize(tests); ++i) { | 73 for (size_t i = 0; i < arraysize(tests); ++i) { |
| 69 const IsAvailableTestData& test = tests[i]; | 74 const IsAvailableTestData& test = tests[i]; |
| 70 EXPECT_EQ(test.expected_result, | 75 EXPECT_EQ(test.expected_result, |
| 71 feature.IsAvailableToManifest(test.extension_id, | 76 feature.IsAvailableToManifest(test.extension_id, |
| 72 test.extension_type, | 77 test.extension_type, |
| 73 test.location, | 78 test.location, |
| 74 test.manifest_version, | 79 test.manifest_version, |
| 75 test.platform).result()); | 80 test.platform).result()); |
| 76 } | 81 } |
| 77 } | 82 } |
| 78 | 83 |
| 79 TEST_F(ExtensionSimpleFeatureTest, Whitelist) { | 84 TEST_F(ExtensionSimpleFeatureTest, Whitelist) { |
| 80 const std::string kIdFoo("fooabbbbccccddddeeeeffffgggghhhh"); | 85 const std::string kIdFoo("fooabbbbccccddddeeeeffffgggghhhh"); |
| 81 const std::string kIdBar("barabbbbccccddddeeeeffffgggghhhh"); | 86 const std::string kIdBar("barabbbbccccddddeeeeffffgggghhhh"); |
| 82 const std::string kIdBaz("bazabbbbccccddddeeeeffffgggghhhh"); | 87 const std::string kIdBaz("bazabbbbccccddddeeeeffffgggghhhh"); |
| 83 SimpleFeature feature; | 88 SimpleFeature feature; |
| 84 feature.whitelist()->insert(kIdFoo); | 89 feature.whitelist()->insert(kIdFoo); |
| 85 feature.whitelist()->insert(kIdBar); | 90 feature.whitelist()->insert(kIdBar); |
| 86 | 91 |
| 87 EXPECT_EQ(Feature::IS_AVAILABLE, feature.IsAvailableToManifest( | 92 EXPECT_EQ( |
| 88 kIdFoo, Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, -1, | 93 Feature::IS_AVAILABLE, |
| 89 Feature::UNSPECIFIED_PLATFORM).result()); | 94 feature.IsAvailableToManifest(kIdFoo, |
| 90 EXPECT_EQ(Feature::IS_AVAILABLE, feature.IsAvailableToManifest( | 95 Manifest::TYPE_UNKNOWN, |
| 91 kIdBar, Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, -1, | 96 Manifest::INVALID_LOCATION, |
| 92 Feature::UNSPECIFIED_PLATFORM).result()); | 97 -1, |
| 98 Feature::UNSPECIFIED_PLATFORM).result()); |
| 99 EXPECT_EQ( |
| 100 Feature::IS_AVAILABLE, |
| 101 feature.IsAvailableToManifest(kIdBar, |
| 102 Manifest::TYPE_UNKNOWN, |
| 103 Manifest::INVALID_LOCATION, |
| 104 -1, |
| 105 Feature::UNSPECIFIED_PLATFORM).result()); |
| 93 | 106 |
| 94 EXPECT_EQ(Feature::NOT_FOUND_IN_WHITELIST, feature.IsAvailableToManifest( | 107 EXPECT_EQ( |
| 95 kIdBaz, Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, -1, | 108 Feature::NOT_FOUND_IN_WHITELIST, |
| 96 Feature::UNSPECIFIED_PLATFORM).result()); | 109 feature.IsAvailableToManifest(kIdBaz, |
| 110 Manifest::TYPE_UNKNOWN, |
| 111 Manifest::INVALID_LOCATION, |
| 112 -1, |
| 113 Feature::UNSPECIFIED_PLATFORM).result()); |
| 97 EXPECT_EQ( | 114 EXPECT_EQ( |
| 98 Feature::NOT_FOUND_IN_WHITELIST, | 115 Feature::NOT_FOUND_IN_WHITELIST, |
| 99 feature.IsAvailableToManifest(std::string(), | 116 feature.IsAvailableToManifest(std::string(), |
| 100 Manifest::TYPE_UNKNOWN, | 117 Manifest::TYPE_UNKNOWN, |
| 101 Feature::UNSPECIFIED_LOCATION, | 118 Manifest::INVALID_LOCATION, |
| 102 -1, | 119 -1, |
| 103 Feature::UNSPECIFIED_PLATFORM).result()); | 120 Feature::UNSPECIFIED_PLATFORM).result()); |
| 104 | 121 |
| 105 feature.extension_types()->insert(Manifest::TYPE_LEGACY_PACKAGED_APP); | 122 feature.extension_types()->insert(Manifest::TYPE_LEGACY_PACKAGED_APP); |
| 106 EXPECT_EQ(Feature::NOT_FOUND_IN_WHITELIST, feature.IsAvailableToManifest( | 123 EXPECT_EQ( |
| 107 kIdBaz, Manifest::TYPE_LEGACY_PACKAGED_APP, | 124 Feature::NOT_FOUND_IN_WHITELIST, |
| 108 Feature::UNSPECIFIED_LOCATION, -1, | 125 feature.IsAvailableToManifest(kIdBaz, |
| 109 Feature::UNSPECIFIED_PLATFORM).result()); | 126 Manifest::TYPE_LEGACY_PACKAGED_APP, |
| 127 Manifest::INVALID_LOCATION, |
| 128 -1, |
| 129 Feature::UNSPECIFIED_PLATFORM).result()); |
| 110 } | 130 } |
| 111 | 131 |
| 112 TEST_F(ExtensionSimpleFeatureTest, HashedIdWhitelist) { | 132 TEST_F(ExtensionSimpleFeatureTest, HashedIdWhitelist) { |
| 113 // echo -n "fooabbbbccccddddeeeeffffgggghhhh" | | 133 // echo -n "fooabbbbccccddddeeeeffffgggghhhh" | |
| 114 // sha1sum | tr '[:lower:]' '[:upper:]' | 134 // sha1sum | tr '[:lower:]' '[:upper:]' |
| 115 const std::string kIdFoo("fooabbbbccccddddeeeeffffgggghhhh"); | 135 const std::string kIdFoo("fooabbbbccccddddeeeeffffgggghhhh"); |
| 116 const std::string kIdFooHashed("55BC7228A0D502A2A48C9BB16B07062A01E62897"); | 136 const std::string kIdFooHashed("55BC7228A0D502A2A48C9BB16B07062A01E62897"); |
| 117 SimpleFeature feature; | 137 SimpleFeature feature; |
| 118 | 138 |
| 119 feature.whitelist()->insert(kIdFooHashed); | 139 feature.whitelist()->insert(kIdFooHashed); |
| 120 | 140 |
| 121 EXPECT_EQ(Feature::IS_AVAILABLE, feature.IsAvailableToManifest( | 141 EXPECT_EQ( |
| 122 kIdFoo, Manifest::TYPE_UNKNOWN, Feature::UNSPECIFIED_LOCATION, -1, | 142 Feature::IS_AVAILABLE, |
| 123 Feature::UNSPECIFIED_PLATFORM).result()); | 143 feature.IsAvailableToManifest(kIdFoo, |
| 124 EXPECT_NE(Feature::IS_AVAILABLE, feature.IsAvailableToManifest( | 144 Manifest::TYPE_UNKNOWN, |
| 125 kIdFooHashed, Manifest::TYPE_UNKNOWN, | 145 Manifest::INVALID_LOCATION, |
| 126 Feature::UNSPECIFIED_LOCATION, -1, | 146 -1, |
| 127 Feature::UNSPECIFIED_PLATFORM).result()); | 147 Feature::UNSPECIFIED_PLATFORM).result()); |
| 128 EXPECT_EQ(Feature::NOT_FOUND_IN_WHITELIST, feature.IsAvailableToManifest( | 148 EXPECT_NE( |
| 129 "slightlytoooolongforanextensionid", Manifest::TYPE_UNKNOWN, | 149 Feature::IS_AVAILABLE, |
| 130 Feature::UNSPECIFIED_LOCATION, -1, | 150 feature.IsAvailableToManifest(kIdFooHashed, |
| 131 Feature::UNSPECIFIED_PLATFORM).result()); | 151 Manifest::TYPE_UNKNOWN, |
| 132 EXPECT_EQ(Feature::NOT_FOUND_IN_WHITELIST, feature.IsAvailableToManifest( | 152 Manifest::INVALID_LOCATION, |
| 133 "tooshortforanextensionid", Manifest::TYPE_UNKNOWN, | 153 -1, |
| 134 Feature::UNSPECIFIED_LOCATION, -1, | 154 Feature::UNSPECIFIED_PLATFORM).result()); |
| 135 Feature::UNSPECIFIED_PLATFORM).result()); | 155 EXPECT_EQ( |
| 156 Feature::NOT_FOUND_IN_WHITELIST, |
| 157 feature.IsAvailableToManifest("slightlytoooolongforanextensionid", |
| 158 Manifest::TYPE_UNKNOWN, |
| 159 Manifest::INVALID_LOCATION, |
| 160 -1, |
| 161 Feature::UNSPECIFIED_PLATFORM).result()); |
| 162 EXPECT_EQ( |
| 163 Feature::NOT_FOUND_IN_WHITELIST, |
| 164 feature.IsAvailableToManifest("tooshortforanextensionid", |
| 165 Manifest::TYPE_UNKNOWN, |
| 166 Manifest::INVALID_LOCATION, |
| 167 -1, |
| 168 Feature::UNSPECIFIED_PLATFORM).result()); |
| 136 } | 169 } |
| 137 | 170 |
| 138 TEST_F(ExtensionSimpleFeatureTest, PackageType) { | 171 TEST_F(ExtensionSimpleFeatureTest, PackageType) { |
| 139 SimpleFeature feature; | 172 SimpleFeature feature; |
| 140 feature.extension_types()->insert(Manifest::TYPE_EXTENSION); | 173 feature.extension_types()->insert(Manifest::TYPE_EXTENSION); |
| 141 feature.extension_types()->insert(Manifest::TYPE_LEGACY_PACKAGED_APP); | 174 feature.extension_types()->insert(Manifest::TYPE_LEGACY_PACKAGED_APP); |
| 142 | 175 |
| 143 EXPECT_EQ( | 176 EXPECT_EQ( |
| 144 Feature::IS_AVAILABLE, | 177 Feature::IS_AVAILABLE, |
| 145 feature.IsAvailableToManifest(std::string(), | 178 feature.IsAvailableToManifest(std::string(), |
| 146 Manifest::TYPE_EXTENSION, | 179 Manifest::TYPE_EXTENSION, |
| 147 Feature::UNSPECIFIED_LOCATION, | 180 Manifest::INVALID_LOCATION, |
| 148 -1, | 181 -1, |
| 149 Feature::UNSPECIFIED_PLATFORM).result()); | 182 Feature::UNSPECIFIED_PLATFORM).result()); |
| 150 EXPECT_EQ( | 183 EXPECT_EQ( |
| 151 Feature::IS_AVAILABLE, | 184 Feature::IS_AVAILABLE, |
| 152 feature.IsAvailableToManifest(std::string(), | 185 feature.IsAvailableToManifest(std::string(), |
| 153 Manifest::TYPE_LEGACY_PACKAGED_APP, | 186 Manifest::TYPE_LEGACY_PACKAGED_APP, |
| 154 Feature::UNSPECIFIED_LOCATION, | 187 Manifest::INVALID_LOCATION, |
| 155 -1, | 188 -1, |
| 156 Feature::UNSPECIFIED_PLATFORM).result()); | 189 Feature::UNSPECIFIED_PLATFORM).result()); |
| 157 | 190 |
| 158 EXPECT_EQ( | 191 EXPECT_EQ( |
| 159 Feature::INVALID_TYPE, | 192 Feature::INVALID_TYPE, |
| 160 feature.IsAvailableToManifest(std::string(), | 193 feature.IsAvailableToManifest(std::string(), |
| 161 Manifest::TYPE_UNKNOWN, | 194 Manifest::TYPE_UNKNOWN, |
| 162 Feature::UNSPECIFIED_LOCATION, | 195 Manifest::INVALID_LOCATION, |
| 163 -1, | 196 -1, |
| 164 Feature::UNSPECIFIED_PLATFORM).result()); | 197 Feature::UNSPECIFIED_PLATFORM).result()); |
| 165 EXPECT_EQ( | 198 EXPECT_EQ( |
| 166 Feature::INVALID_TYPE, | 199 Feature::INVALID_TYPE, |
| 167 feature.IsAvailableToManifest(std::string(), | 200 feature.IsAvailableToManifest(std::string(), |
| 168 Manifest::TYPE_THEME, | 201 Manifest::TYPE_THEME, |
| 169 Feature::UNSPECIFIED_LOCATION, | 202 Manifest::INVALID_LOCATION, |
| 170 -1, | 203 -1, |
| 171 Feature::UNSPECIFIED_PLATFORM).result()); | 204 Feature::UNSPECIFIED_PLATFORM).result()); |
| 172 } | 205 } |
| 173 | 206 |
| 174 TEST_F(ExtensionSimpleFeatureTest, Context) { | 207 TEST_F(ExtensionSimpleFeatureTest, Context) { |
| 175 SimpleFeature feature; | 208 SimpleFeature feature; |
| 176 feature.set_name("somefeature"); | 209 feature.set_name("somefeature"); |
| 177 feature.GetContexts()->insert(Feature::BLESSED_EXTENSION_CONTEXT); | 210 feature.GetContexts()->insert(Feature::BLESSED_EXTENSION_CONTEXT); |
| 178 feature.extension_types()->insert(Manifest::TYPE_LEGACY_PACKAGED_APP); | 211 feature.extension_types()->insert(Manifest::TYPE_LEGACY_PACKAGED_APP); |
| 179 feature.platforms()->insert(Feature::CHROMEOS_PLATFORM); | 212 feature.platforms()->insert(Feature::CHROMEOS_PLATFORM); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 extension.get(), Feature::BLESSED_EXTENSION_CONTEXT, | 265 extension.get(), Feature::BLESSED_EXTENSION_CONTEXT, |
| 233 Feature::CHROMEOS_PLATFORM); | 266 Feature::CHROMEOS_PLATFORM); |
| 234 EXPECT_EQ(Feature::INVALID_CONTEXT, availability.result()); | 267 EXPECT_EQ(Feature::INVALID_CONTEXT, availability.result()); |
| 235 EXPECT_EQ("'somefeature' is only allowed to run in extension iframes, " | 268 EXPECT_EQ("'somefeature' is only allowed to run in extension iframes, " |
| 236 "content scripts, and web pages, but this is a privileged page", | 269 "content scripts, and web pages, but this is a privileged page", |
| 237 availability.message()); | 270 availability.message()); |
| 238 } | 271 } |
| 239 | 272 |
| 240 feature.GetContexts()->clear(); | 273 feature.GetContexts()->clear(); |
| 241 feature.GetContexts()->insert(Feature::BLESSED_EXTENSION_CONTEXT); | 274 feature.GetContexts()->insert(Feature::BLESSED_EXTENSION_CONTEXT); |
| 242 feature.set_location(Feature::COMPONENT_LOCATION); | 275 *feature.locations() = Set(Manifest::COMPONENT); |
| 243 EXPECT_EQ(Feature::INVALID_LOCATION, feature.IsAvailableToContext( | 276 EXPECT_EQ(Feature::INVALID_LOCATION, feature.IsAvailableToContext( |
| 244 extension.get(), Feature::BLESSED_EXTENSION_CONTEXT, | 277 extension.get(), Feature::BLESSED_EXTENSION_CONTEXT, |
| 245 Feature::CHROMEOS_PLATFORM).result()); | 278 Feature::CHROMEOS_PLATFORM).result()); |
| 246 feature.set_location(Feature::UNSPECIFIED_LOCATION); | 279 feature.locations()->clear(); |
| 247 | 280 |
| 248 EXPECT_EQ(Feature::INVALID_PLATFORM, feature.IsAvailableToContext( | 281 EXPECT_EQ(Feature::INVALID_PLATFORM, feature.IsAvailableToContext( |
| 249 extension.get(), Feature::BLESSED_EXTENSION_CONTEXT, | 282 extension.get(), Feature::BLESSED_EXTENSION_CONTEXT, |
| 250 Feature::UNSPECIFIED_PLATFORM).result()); | 283 Feature::UNSPECIFIED_PLATFORM).result()); |
| 251 | 284 |
| 252 feature.set_min_manifest_version(22); | 285 feature.set_min_manifest_version(22); |
| 253 EXPECT_EQ(Feature::INVALID_MIN_MANIFEST_VERSION, feature.IsAvailableToContext( | 286 EXPECT_EQ(Feature::INVALID_MIN_MANIFEST_VERSION, feature.IsAvailableToContext( |
| 254 extension.get(), Feature::BLESSED_EXTENSION_CONTEXT, | 287 extension.get(), Feature::BLESSED_EXTENSION_CONTEXT, |
| 255 Feature::CHROMEOS_PLATFORM).result()); | 288 Feature::CHROMEOS_PLATFORM).result()); |
| 256 feature.set_min_manifest_version(21); | 289 feature.set_min_manifest_version(21); |
| 257 | 290 |
| 258 feature.set_max_manifest_version(18); | 291 feature.set_max_manifest_version(18); |
| 259 EXPECT_EQ(Feature::INVALID_MAX_MANIFEST_VERSION, feature.IsAvailableToContext( | 292 EXPECT_EQ(Feature::INVALID_MAX_MANIFEST_VERSION, feature.IsAvailableToContext( |
| 260 extension.get(), Feature::BLESSED_EXTENSION_CONTEXT, | 293 extension.get(), Feature::BLESSED_EXTENSION_CONTEXT, |
| 261 Feature::CHROMEOS_PLATFORM).result()); | 294 Feature::CHROMEOS_PLATFORM).result()); |
| 262 feature.set_max_manifest_version(25); | 295 feature.set_max_manifest_version(25); |
| 263 } | 296 } |
| 264 | 297 |
| 265 TEST_F(ExtensionSimpleFeatureTest, Location) { | 298 TEST_F(ExtensionSimpleFeatureTest, Location) { |
| 266 SimpleFeature feature; | 299 SimpleFeature feature; |
| 267 | 300 |
| 268 // If the feature specifies "component" as its location, then only component | 301 // If the feature specifies "component" as its location, then only component |
| 269 // extensions can access it. | 302 // extensions can access it. |
| 270 feature.set_location(Feature::COMPONENT_LOCATION); | 303 *feature.locations() = Set(Manifest::COMPONENT); |
| 271 EXPECT_EQ( | 304 EXPECT_EQ( |
| 272 Feature::IS_AVAILABLE, | 305 Feature::IS_AVAILABLE, |
| 273 feature.IsAvailableToManifest(std::string(), | 306 feature.IsAvailableToManifest(std::string(), |
| 274 Manifest::TYPE_UNKNOWN, | 307 Manifest::TYPE_UNKNOWN, |
| 275 Feature::COMPONENT_LOCATION, | 308 Manifest::COMPONENT, |
| 276 -1, | 309 -1, |
| 277 Feature::UNSPECIFIED_PLATFORM).result()); | 310 Feature::UNSPECIFIED_PLATFORM).result()); |
| 278 EXPECT_EQ( | 311 EXPECT_EQ( |
| 279 Feature::INVALID_LOCATION, | 312 Feature::INVALID_LOCATION, |
| 280 feature.IsAvailableToManifest(std::string(), | 313 feature.IsAvailableToManifest(std::string(), |
| 281 Manifest::TYPE_UNKNOWN, | 314 Manifest::TYPE_UNKNOWN, |
| 282 Feature::UNSPECIFIED_LOCATION, | 315 Manifest::INVALID_LOCATION, |
| 283 -1, | 316 -1, |
| 284 Feature::UNSPECIFIED_PLATFORM).result()); | 317 Feature::UNSPECIFIED_PLATFORM).result()); |
| 285 | 318 |
| 286 // But component extensions can access anything else, whatever their location. | 319 // But component extensions can access anything else, whatever their location. |
| 287 feature.set_location(Feature::UNSPECIFIED_LOCATION); | 320 feature.locations()->clear(); |
| 288 EXPECT_EQ( | 321 EXPECT_EQ( |
| 289 Feature::IS_AVAILABLE, | 322 Feature::IS_AVAILABLE, |
| 290 feature.IsAvailableToManifest(std::string(), | 323 feature.IsAvailableToManifest(std::string(), |
| 291 Manifest::TYPE_UNKNOWN, | 324 Manifest::TYPE_UNKNOWN, |
| 292 Feature::COMPONENT_LOCATION, | 325 Manifest::COMPONENT, |
| 293 -1, | 326 -1, |
| 294 Feature::UNSPECIFIED_PLATFORM).result()); | 327 Feature::UNSPECIFIED_PLATFORM).result()); |
| 295 } | 328 } |
| 296 | 329 |
| 297 TEST_F(ExtensionSimpleFeatureTest, Platform) { | 330 TEST_F(ExtensionSimpleFeatureTest, Platform) { |
| 298 SimpleFeature feature; | 331 SimpleFeature feature; |
| 299 feature.platforms()->insert(Feature::CHROMEOS_PLATFORM); | 332 feature.platforms()->insert(Feature::CHROMEOS_PLATFORM); |
| 300 EXPECT_EQ(Feature::IS_AVAILABLE, | 333 EXPECT_EQ(Feature::IS_AVAILABLE, |
| 301 feature.IsAvailableToManifest(std::string(), | 334 feature.IsAvailableToManifest(std::string(), |
| 302 Manifest::TYPE_UNKNOWN, | 335 Manifest::TYPE_UNKNOWN, |
| 303 Feature::UNSPECIFIED_LOCATION, | 336 Manifest::INVALID_LOCATION, |
| 304 -1, | 337 -1, |
| 305 Feature::CHROMEOS_PLATFORM).result()); | 338 Feature::CHROMEOS_PLATFORM).result()); |
| 306 EXPECT_EQ( | 339 EXPECT_EQ( |
| 307 Feature::INVALID_PLATFORM, | 340 Feature::INVALID_PLATFORM, |
| 308 feature.IsAvailableToManifest(std::string(), | 341 feature.IsAvailableToManifest(std::string(), |
| 309 Manifest::TYPE_UNKNOWN, | 342 Manifest::TYPE_UNKNOWN, |
| 310 Feature::UNSPECIFIED_LOCATION, | 343 Manifest::INVALID_LOCATION, |
| 311 -1, | 344 -1, |
| 312 Feature::UNSPECIFIED_PLATFORM).result()); | 345 Feature::UNSPECIFIED_PLATFORM).result()); |
| 313 } | 346 } |
| 314 | 347 |
| 315 TEST_F(ExtensionSimpleFeatureTest, Version) { | 348 TEST_F(ExtensionSimpleFeatureTest, Version) { |
| 316 SimpleFeature feature; | 349 SimpleFeature feature; |
| 317 feature.set_min_manifest_version(5); | 350 feature.set_min_manifest_version(5); |
| 318 | 351 |
| 319 EXPECT_EQ( | 352 EXPECT_EQ( |
| 320 Feature::INVALID_MIN_MANIFEST_VERSION, | 353 Feature::INVALID_MIN_MANIFEST_VERSION, |
| 321 feature.IsAvailableToManifest(std::string(), | 354 feature.IsAvailableToManifest(std::string(), |
| 322 Manifest::TYPE_UNKNOWN, | 355 Manifest::TYPE_UNKNOWN, |
| 323 Feature::UNSPECIFIED_LOCATION, | 356 Manifest::INVALID_LOCATION, |
| 324 0, | 357 0, |
| 325 Feature::UNSPECIFIED_PLATFORM).result()); | 358 Feature::UNSPECIFIED_PLATFORM).result()); |
| 326 EXPECT_EQ( | 359 EXPECT_EQ( |
| 327 Feature::INVALID_MIN_MANIFEST_VERSION, | 360 Feature::INVALID_MIN_MANIFEST_VERSION, |
| 328 feature.IsAvailableToManifest(std::string(), | 361 feature.IsAvailableToManifest(std::string(), |
| 329 Manifest::TYPE_UNKNOWN, | 362 Manifest::TYPE_UNKNOWN, |
| 330 Feature::UNSPECIFIED_LOCATION, | 363 Manifest::INVALID_LOCATION, |
| 331 4, | 364 4, |
| 332 Feature::UNSPECIFIED_PLATFORM).result()); | 365 Feature::UNSPECIFIED_PLATFORM).result()); |
| 333 | 366 |
| 334 EXPECT_EQ( | 367 EXPECT_EQ( |
| 335 Feature::IS_AVAILABLE, | 368 Feature::IS_AVAILABLE, |
| 336 feature.IsAvailableToManifest(std::string(), | 369 feature.IsAvailableToManifest(std::string(), |
| 337 Manifest::TYPE_UNKNOWN, | 370 Manifest::TYPE_UNKNOWN, |
| 338 Feature::UNSPECIFIED_LOCATION, | 371 Manifest::INVALID_LOCATION, |
| 339 5, | 372 5, |
| 340 Feature::UNSPECIFIED_PLATFORM).result()); | 373 Feature::UNSPECIFIED_PLATFORM).result()); |
| 341 EXPECT_EQ( | 374 EXPECT_EQ( |
| 342 Feature::IS_AVAILABLE, | 375 Feature::IS_AVAILABLE, |
| 343 feature.IsAvailableToManifest(std::string(), | 376 feature.IsAvailableToManifest(std::string(), |
| 344 Manifest::TYPE_UNKNOWN, | 377 Manifest::TYPE_UNKNOWN, |
| 345 Feature::UNSPECIFIED_LOCATION, | 378 Manifest::INVALID_LOCATION, |
| 346 10, | 379 10, |
| 347 Feature::UNSPECIFIED_PLATFORM).result()); | 380 Feature::UNSPECIFIED_PLATFORM).result()); |
| 348 | 381 |
| 349 feature.set_max_manifest_version(8); | 382 feature.set_max_manifest_version(8); |
| 350 | 383 |
| 351 EXPECT_EQ( | 384 EXPECT_EQ( |
| 352 Feature::INVALID_MAX_MANIFEST_VERSION, | 385 Feature::INVALID_MAX_MANIFEST_VERSION, |
| 353 feature.IsAvailableToManifest(std::string(), | 386 feature.IsAvailableToManifest(std::string(), |
| 354 Manifest::TYPE_UNKNOWN, | 387 Manifest::TYPE_UNKNOWN, |
| 355 Feature::UNSPECIFIED_LOCATION, | 388 Manifest::INVALID_LOCATION, |
| 356 10, | 389 10, |
| 357 Feature::UNSPECIFIED_PLATFORM).result()); | 390 Feature::UNSPECIFIED_PLATFORM).result()); |
| 358 EXPECT_EQ( | 391 EXPECT_EQ( |
| 359 Feature::IS_AVAILABLE, | 392 Feature::IS_AVAILABLE, |
| 360 feature.IsAvailableToManifest(std::string(), | 393 feature.IsAvailableToManifest(std::string(), |
| 361 Manifest::TYPE_UNKNOWN, | 394 Manifest::TYPE_UNKNOWN, |
| 362 Feature::UNSPECIFIED_LOCATION, | 395 Manifest::INVALID_LOCATION, |
| 363 8, | 396 8, |
| 364 Feature::UNSPECIFIED_PLATFORM).result()); | 397 Feature::UNSPECIFIED_PLATFORM).result()); |
| 365 EXPECT_EQ( | 398 EXPECT_EQ( |
| 366 Feature::IS_AVAILABLE, | 399 Feature::IS_AVAILABLE, |
| 367 feature.IsAvailableToManifest(std::string(), | 400 feature.IsAvailableToManifest(std::string(), |
| 368 Manifest::TYPE_UNKNOWN, | 401 Manifest::TYPE_UNKNOWN, |
| 369 Feature::UNSPECIFIED_LOCATION, | 402 Manifest::INVALID_LOCATION, |
| 370 7, | 403 7, |
| 371 Feature::UNSPECIFIED_PLATFORM).result()); | 404 Feature::UNSPECIFIED_PLATFORM).result()); |
| 372 } | 405 } |
| 373 | 406 |
| 374 TEST_F(ExtensionSimpleFeatureTest, ParseNull) { | 407 TEST_F(ExtensionSimpleFeatureTest, ParseNull) { |
| 375 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 408 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 376 scoped_ptr<SimpleFeature> feature(new SimpleFeature()); | 409 scoped_ptr<SimpleFeature> feature(new SimpleFeature()); |
| 377 feature->Parse(value.get()); | 410 feature->Parse(value.get()); |
| 378 EXPECT_TRUE(feature->whitelist()->empty()); | 411 EXPECT_TRUE(feature->whitelist()->empty()); |
| 379 EXPECT_TRUE(feature->extension_types()->empty()); | 412 EXPECT_TRUE(feature->extension_types()->empty()); |
| 380 EXPECT_TRUE(feature->GetContexts()->empty()); | 413 EXPECT_TRUE(feature->GetContexts()->empty()); |
| 381 EXPECT_EQ(Feature::UNSPECIFIED_LOCATION, feature->location()); | 414 EXPECT_TRUE(feature->locations()->empty()); |
| 382 EXPECT_TRUE(feature->platforms()->empty()); | 415 EXPECT_TRUE(feature->platforms()->empty()); |
| 383 EXPECT_EQ(0, feature->min_manifest_version()); | 416 EXPECT_EQ(0, feature->min_manifest_version()); |
| 384 EXPECT_EQ(0, feature->max_manifest_version()); | 417 EXPECT_EQ(0, feature->max_manifest_version()); |
| 385 } | 418 } |
| 386 | 419 |
| 387 TEST_F(ExtensionSimpleFeatureTest, ParseWhitelist) { | 420 TEST_F(ExtensionSimpleFeatureTest, ParseWhitelist) { |
| 388 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 421 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 389 base::ListValue* whitelist = new base::ListValue(); | 422 base::ListValue* whitelist = new base::ListValue(); |
| 390 whitelist->Append(new base::StringValue("foo")); | 423 whitelist->Append(new base::StringValue("foo")); |
| 391 whitelist->Append(new base::StringValue("bar")); | 424 whitelist->Append(new base::StringValue("bar")); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 feature->GetContexts()->count(Feature::WEB_PAGE_CONTEXT)); | 479 feature->GetContexts()->count(Feature::WEB_PAGE_CONTEXT)); |
| 447 EXPECT_TRUE( | 480 EXPECT_TRUE( |
| 448 feature->GetContexts()->count(Feature::BLESSED_WEB_PAGE_CONTEXT)); | 481 feature->GetContexts()->count(Feature::BLESSED_WEB_PAGE_CONTEXT)); |
| 449 | 482 |
| 450 value->SetString("contexts", "all"); | 483 value->SetString("contexts", "all"); |
| 451 scoped_ptr<SimpleFeature> feature2(new SimpleFeature()); | 484 scoped_ptr<SimpleFeature> feature2(new SimpleFeature()); |
| 452 feature2->Parse(value.get()); | 485 feature2->Parse(value.get()); |
| 453 EXPECT_EQ(*(feature->GetContexts()), *(feature2->GetContexts())); | 486 EXPECT_EQ(*(feature->GetContexts()), *(feature2->GetContexts())); |
| 454 } | 487 } |
| 455 | 488 |
| 456 TEST_F(ExtensionSimpleFeatureTest, ParseLocation) { | 489 TEST_F(ExtensionSimpleFeatureTest, ParseComponentLocation) { |
| 457 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 490 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 458 value->SetString("location", "component"); | 491 value->SetString("location", "component"); |
| 459 scoped_ptr<SimpleFeature> feature(new SimpleFeature()); | 492 scoped_ptr<SimpleFeature> feature(new SimpleFeature()); |
| 460 feature->Parse(value.get()); | 493 feature->Parse(value.get()); |
| 461 EXPECT_EQ(Feature::COMPONENT_LOCATION, feature->location()); | 494 EXPECT_EQ(Set(Manifest::COMPONENT, Manifest::EXTERNAL_COMPONENT), |
| 495 *feature->locations()); |
| 496 } |
| 497 |
| 498 TEST_F(ExtensionSimpleFeatureTest, ParsePolicyLocation) { |
| 499 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 500 value->SetString("location", "policy"); |
| 501 scoped_ptr<SimpleFeature> feature(new SimpleFeature()); |
| 502 feature->Parse(value.get()); |
| 503 EXPECT_EQ(Set(Manifest::EXTERNAL_POLICY, Manifest::EXTERNAL_POLICY_DOWNLOAD), |
| 504 *feature->locations()); |
| 462 } | 505 } |
| 463 | 506 |
| 464 TEST_F(ExtensionSimpleFeatureTest, ParsePlatforms) { | 507 TEST_F(ExtensionSimpleFeatureTest, ParsePlatforms) { |
| 465 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 508 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 466 scoped_ptr<SimpleFeature> feature(new SimpleFeature()); | 509 scoped_ptr<SimpleFeature> feature(new SimpleFeature()); |
| 467 base::ListValue* platforms = new base::ListValue(); | 510 base::ListValue* platforms = new base::ListValue(); |
| 468 value->Set("platforms", platforms); | 511 value->Set("platforms", platforms); |
| 469 feature->Parse(value.get()); | 512 feature->Parse(value.get()); |
| 470 EXPECT_TRUE(feature->platforms()->empty()); | 513 EXPECT_TRUE(feature->platforms()->empty()); |
| 471 | 514 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 500 feature->Parse(value.get()); | 543 feature->Parse(value.get()); |
| 501 EXPECT_EQ(1, feature->min_manifest_version()); | 544 EXPECT_EQ(1, feature->min_manifest_version()); |
| 502 EXPECT_EQ(5, feature->max_manifest_version()); | 545 EXPECT_EQ(5, feature->max_manifest_version()); |
| 503 } | 546 } |
| 504 | 547 |
| 505 TEST_F(ExtensionSimpleFeatureTest, Inheritance) { | 548 TEST_F(ExtensionSimpleFeatureTest, Inheritance) { |
| 506 SimpleFeature feature; | 549 SimpleFeature feature; |
| 507 feature.whitelist()->insert("foo"); | 550 feature.whitelist()->insert("foo"); |
| 508 feature.extension_types()->insert(Manifest::TYPE_THEME); | 551 feature.extension_types()->insert(Manifest::TYPE_THEME); |
| 509 feature.GetContexts()->insert(Feature::BLESSED_EXTENSION_CONTEXT); | 552 feature.GetContexts()->insert(Feature::BLESSED_EXTENSION_CONTEXT); |
| 510 feature.set_location(Feature::COMPONENT_LOCATION); | 553 *feature.locations() = Set(Manifest::COMPONENT); |
| 511 feature.platforms()->insert(Feature::CHROMEOS_PLATFORM); | 554 feature.platforms()->insert(Feature::CHROMEOS_PLATFORM); |
| 512 feature.set_min_manifest_version(1); | 555 feature.set_min_manifest_version(1); |
| 513 feature.set_max_manifest_version(2); | 556 feature.set_max_manifest_version(2); |
| 514 | 557 |
| 515 // Test additive parsing. Parsing an empty dictionary should result in no | 558 // Test additive parsing. Parsing an empty dictionary should result in no |
| 516 // changes to a SimpleFeature. | 559 // changes to a SimpleFeature. |
| 517 base::DictionaryValue definition; | 560 base::DictionaryValue definition; |
| 518 feature.Parse(&definition); | 561 feature.Parse(&definition); |
| 519 EXPECT_EQ(1u, feature.whitelist()->size()); | 562 EXPECT_EQ(Set(std::string("foo")), *feature.whitelist()); |
| 520 EXPECT_EQ(1u, feature.extension_types()->size()); | 563 EXPECT_EQ(Set(Manifest::TYPE_THEME), *feature.extension_types()); |
| 521 EXPECT_EQ(1u, feature.GetContexts()->size()); | 564 EXPECT_EQ(Set(Feature::BLESSED_EXTENSION_CONTEXT), *feature.GetContexts()); |
| 522 EXPECT_EQ(1u, feature.whitelist()->count("foo")); | 565 EXPECT_EQ(Set(Manifest::COMPONENT), *feature.locations()); |
| 523 EXPECT_EQ(Feature::COMPONENT_LOCATION, feature.location()); | 566 EXPECT_EQ(Set(Feature::CHROMEOS_PLATFORM), *feature.platforms()); |
| 524 EXPECT_EQ(1u, feature.platforms()->size()); | |
| 525 EXPECT_EQ(1u, feature.platforms()->count(Feature::CHROMEOS_PLATFORM)); | |
| 526 EXPECT_EQ(1, feature.min_manifest_version()); | 567 EXPECT_EQ(1, feature.min_manifest_version()); |
| 527 EXPECT_EQ(2, feature.max_manifest_version()); | 568 EXPECT_EQ(2, feature.max_manifest_version()); |
| 528 | 569 |
| 529 base::ListValue* whitelist = new base::ListValue(); | 570 base::ListValue* whitelist = new base::ListValue(); |
| 530 base::ListValue* extension_types = new base::ListValue(); | 571 base::ListValue* extension_types = new base::ListValue(); |
| 531 base::ListValue* contexts = new base::ListValue(); | 572 base::ListValue* contexts = new base::ListValue(); |
| 532 whitelist->Append(new base::StringValue("bar")); | 573 whitelist->Append(new base::StringValue("bar")); |
| 533 extension_types->Append(new base::StringValue("extension")); | 574 extension_types->Append(new base::StringValue("extension")); |
| 534 contexts->Append(new base::StringValue("unblessed_extension")); | 575 contexts->Append(new base::StringValue("unblessed_extension")); |
| 535 definition.Set("whitelist", whitelist); | 576 definition.Set("whitelist", whitelist); |
| 536 definition.Set("extension_types", extension_types); | 577 definition.Set("extension_types", extension_types); |
| 537 definition.Set("contexts", contexts); | 578 definition.Set("contexts", contexts); |
| 538 // Can't test location or platform because we only have one value so far. | 579 definition.SetString("location", "policy"); |
| 580 // Can't test platform because we only have one value so far. |
| 539 definition.Set("min_manifest_version", new base::FundamentalValue(2)); | 581 definition.Set("min_manifest_version", new base::FundamentalValue(2)); |
| 540 definition.Set("max_manifest_version", new base::FundamentalValue(3)); | 582 definition.Set("max_manifest_version", new base::FundamentalValue(3)); |
| 541 | 583 |
| 542 feature.Parse(&definition); | 584 feature.Parse(&definition); |
| 543 EXPECT_EQ(1u, feature.whitelist()->size()); | 585 EXPECT_EQ(Set(std::string("bar")), *feature.whitelist()); |
| 544 EXPECT_EQ(1u, feature.extension_types()->size()); | 586 EXPECT_EQ(Set(Manifest::TYPE_EXTENSION), *feature.extension_types()); |
| 545 EXPECT_EQ(1u, feature.GetContexts()->size()); | 587 EXPECT_EQ(Set(Feature::UNBLESSED_EXTENSION_CONTEXT), *feature.GetContexts()); |
| 546 EXPECT_EQ(1u, feature.whitelist()->count("bar")); | 588 EXPECT_EQ(Set(Manifest::EXTERNAL_POLICY, Manifest::EXTERNAL_POLICY_DOWNLOAD), |
| 547 EXPECT_EQ(1u, feature.extension_types()->count(Manifest::TYPE_EXTENSION)); | 589 *feature.locations()); |
| 548 EXPECT_EQ(1u, | 590 EXPECT_EQ(Set(Feature::CHROMEOS_PLATFORM), *feature.platforms()); |
| 549 feature.GetContexts()->count(Feature::UNBLESSED_EXTENSION_CONTEXT)); | |
| 550 EXPECT_EQ(2, feature.min_manifest_version()); | 591 EXPECT_EQ(2, feature.min_manifest_version()); |
| 551 EXPECT_EQ(3, feature.max_manifest_version()); | 592 EXPECT_EQ(3, feature.max_manifest_version()); |
| 552 } | 593 } |
| 553 | 594 |
| 554 Feature::AvailabilityResult IsAvailableInChannel( | 595 Feature::AvailabilityResult IsAvailableInChannel( |
| 555 const std::string& channel, VersionInfo::Channel channel_for_testing) { | 596 const std::string& channel, VersionInfo::Channel channel_for_testing) { |
| 556 ScopedCurrentChannel current_channel(channel_for_testing); | 597 ScopedCurrentChannel current_channel(channel_for_testing); |
| 557 | 598 |
| 558 SimpleFeature feature; | 599 SimpleFeature feature; |
| 559 feature.AddFilter(scoped_ptr<extensions::SimpleFeatureFilter>( | 600 feature.AddFilter(scoped_ptr<extensions::SimpleFeatureFilter>( |
| 560 new extensions::ChromeChannelFeatureFilter(&feature))); | 601 new extensions::ChromeChannelFeatureFilter(&feature))); |
| 561 if (!channel.empty()) { | 602 if (!channel.empty()) { |
| 562 base::DictionaryValue feature_value; | 603 base::DictionaryValue feature_value; |
| 563 feature_value.SetString("channel", channel); | 604 feature_value.SetString("channel", channel); |
| 564 feature.Parse(&feature_value); | 605 feature.Parse(&feature_value); |
| 565 } | 606 } |
| 566 | 607 |
| 567 return feature.IsAvailableToManifest( | 608 return feature.IsAvailableToManifest("random-extension", |
| 568 "random-extension", | 609 Manifest::TYPE_UNKNOWN, |
| 569 Manifest::TYPE_UNKNOWN, | 610 Manifest::INVALID_LOCATION, |
| 570 Feature::UNSPECIFIED_LOCATION, | 611 -1, |
| 571 -1, | 612 Feature::GetCurrentPlatform()).result(); |
| 572 Feature::GetCurrentPlatform()).result(); | |
| 573 } | 613 } |
| 574 | 614 |
| 575 TEST_F(ExtensionSimpleFeatureTest, SupportedChannel) { | 615 TEST_F(ExtensionSimpleFeatureTest, SupportedChannel) { |
| 576 // stable supported. | 616 // stable supported. |
| 577 EXPECT_EQ(Feature::IS_AVAILABLE, | 617 EXPECT_EQ(Feature::IS_AVAILABLE, |
| 578 IsAvailableInChannel("stable", VersionInfo::CHANNEL_UNKNOWN)); | 618 IsAvailableInChannel("stable", VersionInfo::CHANNEL_UNKNOWN)); |
| 579 EXPECT_EQ(Feature::IS_AVAILABLE, | 619 EXPECT_EQ(Feature::IS_AVAILABLE, |
| 580 IsAvailableInChannel("stable", VersionInfo::CHANNEL_CANARY)); | 620 IsAvailableInChannel("stable", VersionInfo::CHANNEL_CANARY)); |
| 581 EXPECT_EQ(Feature::IS_AVAILABLE, | 621 EXPECT_EQ(Feature::IS_AVAILABLE, |
| 582 IsAvailableInChannel("stable", VersionInfo::CHANNEL_DEV)); | 622 IsAvailableInChannel("stable", VersionInfo::CHANNEL_DEV)); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_CANARY)); | 668 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_CANARY)); |
| 629 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, | 669 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, |
| 630 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_DEV)); | 670 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_DEV)); |
| 631 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, | 671 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, |
| 632 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_BETA)); | 672 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_BETA)); |
| 633 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, | 673 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, |
| 634 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_STABLE)); | 674 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_STABLE)); |
| 635 } | 675 } |
| 636 | 676 |
| 637 } // namespace | 677 } // namespace |
| OLD | NEW |