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

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

Issue 2236443003: extensions: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't add braces Created 4 years, 4 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/extension_set.cc ('k') | extensions/common/features/simple_feature.cc » ('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/base_feature_provider.h" 5 #include "extensions/common/features/base_feature_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 12 matching lines...) Expand all
23 // extensions and apps. 23 // extensions and apps.
24 TEST(BaseFeatureProviderTest, ManifestFeatureTypes) { 24 TEST(BaseFeatureProviderTest, ManifestFeatureTypes) {
25 // NOTE: This feature cannot have multiple rules, otherwise it is not a 25 // NOTE: This feature cannot have multiple rules, otherwise it is not a
26 // SimpleFeature. 26 // SimpleFeature.
27 const SimpleFeature* feature = static_cast<const SimpleFeature*>( 27 const SimpleFeature* feature = static_cast<const SimpleFeature*>(
28 FeatureProvider::GetManifestFeature("description")); 28 FeatureProvider::GetManifestFeature("description"));
29 ASSERT_TRUE(feature); 29 ASSERT_TRUE(feature);
30 const std::vector<Manifest::Type>& extension_types = 30 const std::vector<Manifest::Type>& extension_types =
31 feature->extension_types(); 31 feature->extension_types();
32 EXPECT_EQ(6u, extension_types.size()); 32 EXPECT_EQ(6u, extension_types.size());
33 EXPECT_EQ(1, STLCount(extension_types, Manifest::TYPE_EXTENSION)); 33 EXPECT_EQ(1, base::STLCount(extension_types, Manifest::TYPE_EXTENSION));
34 EXPECT_EQ(1, STLCount(extension_types, Manifest::TYPE_LEGACY_PACKAGED_APP)); 34 EXPECT_EQ(
35 EXPECT_EQ(1, STLCount(extension_types, Manifest::TYPE_PLATFORM_APP)); 35 1, base::STLCount(extension_types, Manifest::TYPE_LEGACY_PACKAGED_APP));
36 EXPECT_EQ(1, STLCount(extension_types, Manifest::TYPE_HOSTED_APP)); 36 EXPECT_EQ(1, base::STLCount(extension_types, Manifest::TYPE_PLATFORM_APP));
37 EXPECT_EQ(1, STLCount(extension_types, Manifest::TYPE_THEME)); 37 EXPECT_EQ(1, base::STLCount(extension_types, Manifest::TYPE_HOSTED_APP));
38 EXPECT_EQ(1, STLCount(extension_types, Manifest::TYPE_SHARED_MODULE)); 38 EXPECT_EQ(1, base::STLCount(extension_types, Manifest::TYPE_THEME));
39 EXPECT_EQ(1, base::STLCount(extension_types, Manifest::TYPE_SHARED_MODULE));
39 } 40 }
40 41
41 // Tests that real manifest features have the correct availability for an 42 // Tests that real manifest features have the correct availability for an
42 // extension. 43 // extension.
43 TEST(BaseFeatureProviderTest, ManifestFeatureAvailability) { 44 TEST(BaseFeatureProviderTest, ManifestFeatureAvailability) {
44 const FeatureProvider* provider = BaseFeatureProvider::GetByName("manifest"); 45 const FeatureProvider* provider = BaseFeatureProvider::GetByName("manifest");
45 46
46 scoped_refptr<const Extension> extension = 47 scoped_refptr<const Extension> extension =
47 ExtensionBuilder() 48 ExtensionBuilder()
48 .SetManifest(DictionaryBuilder() 49 .SetManifest(DictionaryBuilder()
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // extensions and apps. 81 // extensions and apps.
81 TEST(BaseFeatureProviderTest, PermissionFeatureTypes) { 82 TEST(BaseFeatureProviderTest, PermissionFeatureTypes) {
82 // NOTE: This feature cannot have multiple rules, otherwise it is not a 83 // NOTE: This feature cannot have multiple rules, otherwise it is not a
83 // SimpleFeature. 84 // SimpleFeature.
84 const SimpleFeature* feature = static_cast<const SimpleFeature*>( 85 const SimpleFeature* feature = static_cast<const SimpleFeature*>(
85 BaseFeatureProvider::GetPermissionFeature("power")); 86 BaseFeatureProvider::GetPermissionFeature("power"));
86 ASSERT_TRUE(feature); 87 ASSERT_TRUE(feature);
87 const std::vector<Manifest::Type>& extension_types = 88 const std::vector<Manifest::Type>& extension_types =
88 feature->extension_types(); 89 feature->extension_types();
89 EXPECT_EQ(3u, extension_types.size()); 90 EXPECT_EQ(3u, extension_types.size());
90 EXPECT_EQ(1, STLCount(extension_types, Manifest::TYPE_EXTENSION)); 91 EXPECT_EQ(1, base::STLCount(extension_types, Manifest::TYPE_EXTENSION));
91 EXPECT_EQ(1, STLCount(extension_types, Manifest::TYPE_LEGACY_PACKAGED_APP)); 92 EXPECT_EQ(
92 EXPECT_EQ(1, STLCount(extension_types, Manifest::TYPE_PLATFORM_APP)); 93 1, base::STLCount(extension_types, Manifest::TYPE_LEGACY_PACKAGED_APP));
94 EXPECT_EQ(1, base::STLCount(extension_types, Manifest::TYPE_PLATFORM_APP));
93 } 95 }
94 96
95 // Tests that real permission features have the correct availability for an app. 97 // Tests that real permission features have the correct availability for an app.
96 TEST(BaseFeatureProviderTest, PermissionFeatureAvailability) { 98 TEST(BaseFeatureProviderTest, PermissionFeatureAvailability) {
97 const FeatureProvider* provider = 99 const FeatureProvider* provider =
98 BaseFeatureProvider::GetByName("permission"); 100 BaseFeatureProvider::GetByName("permission");
99 101
100 scoped_refptr<const Extension> app = 102 scoped_refptr<const Extension> app =
101 ExtensionBuilder() 103 ExtensionBuilder()
102 .SetManifest( 104 .SetManifest(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // A permission that isn't part of the manifest returns NOT_PRESENT. 139 // A permission that isn't part of the manifest returns NOT_PRESENT.
138 feature = provider->GetFeature("serial"); 140 feature = provider->GetFeature("serial");
139 ASSERT_TRUE(feature); 141 ASSERT_TRUE(feature);
140 EXPECT_EQ( 142 EXPECT_EQ(
141 Feature::NOT_PRESENT, 143 Feature::NOT_PRESENT,
142 feature->IsAvailableToContext( 144 feature->IsAvailableToContext(
143 app.get(), Feature::UNSPECIFIED_CONTEXT, GURL()).result()); 145 app.get(), Feature::UNSPECIFIED_CONTEXT, GURL()).result());
144 } 146 }
145 147
146 } // namespace extensions 148 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/extension_set.cc ('k') | extensions/common/features/simple_feature.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698