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

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

Issue 789383002: Add the basic infrastructure for the Behavior feature type: BehaviorFeature and (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@flag-features
Patch Set: rebase Created 6 years 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') | extensions/extensions.gyp » ('j') | 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 <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 EXPECT_EQ(Feature::INVALID_MAX_MANIFEST_VERSION, feature.IsAvailableToContext( 373 EXPECT_EQ(Feature::INVALID_MAX_MANIFEST_VERSION, feature.IsAvailableToContext(
374 extension.get(), Feature::BLESSED_EXTENSION_CONTEXT, 374 extension.get(), Feature::BLESSED_EXTENSION_CONTEXT,
375 Feature::CHROMEOS_PLATFORM).result()); 375 Feature::CHROMEOS_PLATFORM).result());
376 feature.set_max_manifest_version(25); 376 feature.set_max_manifest_version(25);
377 } 377 }
378 378
379 TEST(SimpleFeatureTest, Location) { 379 TEST(SimpleFeatureTest, Location) {
380 // Component extensions can access any location. 380 // Component extensions can access any location.
381 EXPECT_TRUE(LocationIsAvailable(SimpleFeature::COMPONENT_LOCATION, 381 EXPECT_TRUE(LocationIsAvailable(SimpleFeature::COMPONENT_LOCATION,
382 Manifest::COMPONENT)); 382 Manifest::COMPONENT));
383 EXPECT_TRUE(LocationIsAvailable(SimpleFeature::EXTERNAL_COMPONENT_LOCATION,
384 Manifest::COMPONENT));
383 EXPECT_TRUE( 385 EXPECT_TRUE(
384 LocationIsAvailable(SimpleFeature::POLICY_LOCATION, Manifest::COMPONENT)); 386 LocationIsAvailable(SimpleFeature::POLICY_LOCATION, Manifest::COMPONENT));
385 EXPECT_TRUE(LocationIsAvailable(SimpleFeature::UNSPECIFIED_LOCATION, 387 EXPECT_TRUE(LocationIsAvailable(SimpleFeature::UNSPECIFIED_LOCATION,
386 Manifest::COMPONENT)); 388 Manifest::COMPONENT));
387 389
388 // Only component extensions can access the "component" location. 390 // Only component extensions can access the "component" location.
389 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::COMPONENT_LOCATION, 391 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::COMPONENT_LOCATION,
390 Manifest::INVALID_LOCATION)); 392 Manifest::INVALID_LOCATION));
391 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::COMPONENT_LOCATION, 393 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::COMPONENT_LOCATION,
392 Manifest::UNPACKED)); 394 Manifest::UNPACKED));
393 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::COMPONENT_LOCATION, 395 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::COMPONENT_LOCATION,
396 Manifest::EXTERNAL_COMPONENT));
397 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::COMPONENT_LOCATION,
394 Manifest::EXTERNAL_PREF_DOWNLOAD)); 398 Manifest::EXTERNAL_PREF_DOWNLOAD));
395 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::COMPONENT_LOCATION, 399 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::COMPONENT_LOCATION,
396 Manifest::EXTERNAL_POLICY)); 400 Manifest::EXTERNAL_POLICY));
397 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::COMPONENT_LOCATION, 401 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::COMPONENT_LOCATION,
398 Manifest::EXTERNAL_POLICY_DOWNLOAD)); 402 Manifest::EXTERNAL_POLICY_DOWNLOAD));
399 403
400 // Policy extensions can access the "policy" location. 404 // Policy extensions can access the "policy" location.
401 EXPECT_TRUE(LocationIsAvailable(SimpleFeature::POLICY_LOCATION, 405 EXPECT_TRUE(LocationIsAvailable(SimpleFeature::POLICY_LOCATION,
402 Manifest::EXTERNAL_POLICY)); 406 Manifest::EXTERNAL_POLICY));
403 EXPECT_TRUE(LocationIsAvailable(SimpleFeature::POLICY_LOCATION, 407 EXPECT_TRUE(LocationIsAvailable(SimpleFeature::POLICY_LOCATION,
404 Manifest::EXTERNAL_POLICY_DOWNLOAD)); 408 Manifest::EXTERNAL_POLICY_DOWNLOAD));
405 409
406 // Non-policy (except component) extensions cannot access policy. 410 // Non-policy (except component) extensions cannot access policy.
407 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::POLICY_LOCATION, 411 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::POLICY_LOCATION,
412 Manifest::EXTERNAL_COMPONENT));
413 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::POLICY_LOCATION,
408 Manifest::INVALID_LOCATION)); 414 Manifest::INVALID_LOCATION));
409 EXPECT_FALSE( 415 EXPECT_FALSE(
410 LocationIsAvailable(SimpleFeature::POLICY_LOCATION, Manifest::UNPACKED)); 416 LocationIsAvailable(SimpleFeature::POLICY_LOCATION, Manifest::UNPACKED));
411 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::POLICY_LOCATION, 417 EXPECT_FALSE(LocationIsAvailable(SimpleFeature::POLICY_LOCATION,
412 Manifest::EXTERNAL_PREF_DOWNLOAD)); 418 Manifest::EXTERNAL_PREF_DOWNLOAD));
419
420 // External component extensions can access the "external_component"
421 // location.
422 EXPECT_TRUE(LocationIsAvailable(SimpleFeature::EXTERNAL_COMPONENT_LOCATION,
423 Manifest::EXTERNAL_COMPONENT));
413 } 424 }
414 425
415 TEST(SimpleFeatureTest, Platform) { 426 TEST(SimpleFeatureTest, Platform) {
416 SimpleFeature feature; 427 SimpleFeature feature;
417 feature.platforms()->insert(Feature::CHROMEOS_PLATFORM); 428 feature.platforms()->insert(Feature::CHROMEOS_PLATFORM);
418 EXPECT_EQ(Feature::IS_AVAILABLE, 429 EXPECT_EQ(Feature::IS_AVAILABLE,
419 feature.IsAvailableToManifest(std::string(), 430 feature.IsAvailableToManifest(std::string(),
420 Manifest::TYPE_UNKNOWN, 431 Manifest::TYPE_UNKNOWN,
421 Manifest::INVALID_LOCATION, 432 Manifest::INVALID_LOCATION,
422 -1, 433 -1,
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 feature.IsAvailableToEnvironment().result()); 704 feature.IsAvailableToEnvironment().result());
694 } 705 }
695 { 706 {
696 ScopedCommandLineSwitch scoped_switch("laser-beams=0"); 707 ScopedCommandLineSwitch scoped_switch("laser-beams=0");
697 EXPECT_EQ(Feature::MISSING_COMMAND_LINE_SWITCH, 708 EXPECT_EQ(Feature::MISSING_COMMAND_LINE_SWITCH,
698 feature.IsAvailableToEnvironment().result()); 709 feature.IsAvailableToEnvironment().result());
699 } 710 }
700 } 711 }
701 712
702 } // namespace extensions 713 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/features/simple_feature.cc ('k') | extensions/extensions.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698