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

Side by Side Diff: extensions/common/features/simple_feature_unittest.cc

Issue 265503003: Enable file_handlers and chrome.app.runtime for QuickOffice. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback, less hacky Created 6 years, 7 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
« no previous file with comments | « extensions/common/features/simple_feature.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 Feature::UNSPECIFIED_PLATFORM).result()); 165 Feature::UNSPECIFIED_PLATFORM).result());
166 EXPECT_EQ( 166 EXPECT_EQ(
167 Feature::NOT_FOUND_IN_WHITELIST, 167 Feature::NOT_FOUND_IN_WHITELIST,
168 feature.IsAvailableToManifest("tooshortforanextensionid", 168 feature.IsAvailableToManifest("tooshortforanextensionid",
169 Manifest::TYPE_UNKNOWN, 169 Manifest::TYPE_UNKNOWN,
170 Manifest::INVALID_LOCATION, 170 Manifest::INVALID_LOCATION,
171 -1, 171 -1,
172 Feature::UNSPECIFIED_PLATFORM).result()); 172 Feature::UNSPECIFIED_PLATFORM).result());
173 } 173 }
174 174
175 TEST_F(ExtensionSimpleFeatureTest, Blacklist) {
176 const std::string kIdFoo("fooabbbbccccddddeeeeffffgggghhhh");
177 const std::string kIdBar("barabbbbccccddddeeeeffffgggghhhh");
178 const std::string kIdBaz("bazabbbbccccddddeeeeffffgggghhhh");
179 SimpleFeature feature;
180 feature.blacklist()->insert(kIdFoo);
181 feature.blacklist()->insert(kIdBar);
182
183 EXPECT_EQ(
184 Feature::FOUND_IN_BLACKLIST,
185 feature.IsAvailableToManifest(kIdFoo,
186 Manifest::TYPE_UNKNOWN,
187 Manifest::INVALID_LOCATION,
188 -1,
189 Feature::UNSPECIFIED_PLATFORM).result());
190 EXPECT_EQ(
191 Feature::FOUND_IN_BLACKLIST,
192 feature.IsAvailableToManifest(kIdBar,
193 Manifest::TYPE_UNKNOWN,
194 Manifest::INVALID_LOCATION,
195 -1,
196 Feature::UNSPECIFIED_PLATFORM).result());
197
198 EXPECT_EQ(
199 Feature::IS_AVAILABLE,
200 feature.IsAvailableToManifest(kIdBaz,
201 Manifest::TYPE_UNKNOWN,
202 Manifest::INVALID_LOCATION,
203 -1,
204 Feature::UNSPECIFIED_PLATFORM).result());
205 EXPECT_EQ(
206 Feature::IS_AVAILABLE,
207 feature.IsAvailableToManifest(std::string(),
208 Manifest::TYPE_UNKNOWN,
209 Manifest::INVALID_LOCATION,
210 -1,
211 Feature::UNSPECIFIED_PLATFORM).result());
212 }
213
214 TEST_F(ExtensionSimpleFeatureTest, HashedIdBlacklist) {
215 // echo -n "fooabbbbccccddddeeeeffffgggghhhh" |
216 // sha1sum | tr '[:lower:]' '[:upper:]'
217 const std::string kIdFoo("fooabbbbccccddddeeeeffffgggghhhh");
218 const std::string kIdFooHashed("55BC7228A0D502A2A48C9BB16B07062A01E62897");
219 SimpleFeature feature;
220
221 feature.blacklist()->insert(kIdFooHashed);
222
223 EXPECT_EQ(
224 Feature::FOUND_IN_BLACKLIST,
225 feature.IsAvailableToManifest(kIdFoo,
226 Manifest::TYPE_UNKNOWN,
227 Manifest::INVALID_LOCATION,
228 -1,
229 Feature::UNSPECIFIED_PLATFORM).result());
230 EXPECT_NE(
231 Feature::FOUND_IN_BLACKLIST,
232 feature.IsAvailableToManifest(kIdFooHashed,
233 Manifest::TYPE_UNKNOWN,
234 Manifest::INVALID_LOCATION,
235 -1,
236 Feature::UNSPECIFIED_PLATFORM).result());
237 EXPECT_EQ(
238 Feature::IS_AVAILABLE,
239 feature.IsAvailableToManifest("slightlytoooolongforanextensionid",
240 Manifest::TYPE_UNKNOWN,
241 Manifest::INVALID_LOCATION,
242 -1,
243 Feature::UNSPECIFIED_PLATFORM).result());
244 EXPECT_EQ(
245 Feature::IS_AVAILABLE,
246 feature.IsAvailableToManifest("tooshortforanextensionid",
247 Manifest::TYPE_UNKNOWN,
248 Manifest::INVALID_LOCATION,
249 -1,
250 Feature::UNSPECIFIED_PLATFORM).result());
251 }
252
175 TEST_F(ExtensionSimpleFeatureTest, PackageType) { 253 TEST_F(ExtensionSimpleFeatureTest, PackageType) {
176 SimpleFeature feature; 254 SimpleFeature feature;
177 feature.extension_types()->insert(Manifest::TYPE_EXTENSION); 255 feature.extension_types()->insert(Manifest::TYPE_EXTENSION);
178 feature.extension_types()->insert(Manifest::TYPE_LEGACY_PACKAGED_APP); 256 feature.extension_types()->insert(Manifest::TYPE_LEGACY_PACKAGED_APP);
179 257
180 EXPECT_EQ( 258 EXPECT_EQ(
181 Feature::IS_AVAILABLE, 259 Feature::IS_AVAILABLE,
182 feature.IsAvailableToManifest(std::string(), 260 feature.IsAvailableToManifest(std::string(),
183 Manifest::TYPE_EXTENSION, 261 Manifest::TYPE_EXTENSION,
184 Manifest::INVALID_LOCATION, 262 Manifest::INVALID_LOCATION,
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_CANARY)); 746 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_CANARY));
669 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, 747 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL,
670 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_DEV)); 748 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_DEV));
671 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, 749 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL,
672 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_BETA)); 750 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_BETA));
673 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, 751 EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL,
674 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_STABLE)); 752 IsAvailableInChannel("trunk", VersionInfo::CHANNEL_STABLE));
675 } 753 }
676 754
677 } // namespace extensions 755 } // namespace extensions
OLDNEW
« 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