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

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

Issue 13997002: Load extensions features file separately when needed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
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/permission_feature.h" 7 #include "chrome/common/extensions/features/permission_feature.h"
8 #include "chrome/common/extensions/value_builder.h" 8 #include "chrome/common/extensions/value_builder.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 using chrome::VersionInfo; 11 using chrome::VersionInfo;
12 using extensions::BaseFeatureProvider; 12 using extensions::BaseFeatureProvider;
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::PermissionFeature; 18 using extensions::PermissionFeature;
19 using extensions::SimpleFeature; 19 using extensions::SimpleFeature;
20 20
21 TEST(BaseFeatureProvider, ManifestFeatures) { 21 TEST(BaseFeatureProvider, ManifestFeatures) {
22 BaseFeatureProvider* provider = 22 BaseFeatureProvider* provider =
23 BaseFeatureProvider::GetManifestFeatures(); 23 BaseFeatureProvider::GetFeaturesByName("manifest");
24 SimpleFeature* feature = 24 SimpleFeature* feature =
25 static_cast<SimpleFeature*>(provider->GetFeature("description")); 25 static_cast<SimpleFeature*>(provider->GetFeature("description"));
26 ASSERT_TRUE(feature); 26 ASSERT_TRUE(feature);
27 EXPECT_EQ(5u, feature->extension_types()->size()); 27 EXPECT_EQ(5u, feature->extension_types()->size());
28 EXPECT_EQ(1u, feature->extension_types()->count(Manifest::TYPE_EXTENSION)); 28 EXPECT_EQ(1u, feature->extension_types()->count(Manifest::TYPE_EXTENSION));
29 EXPECT_EQ(1u, 29 EXPECT_EQ(1u,
30 feature->extension_types()->count(Manifest::TYPE_LEGACY_PACKAGED_APP)); 30 feature->extension_types()->count(Manifest::TYPE_LEGACY_PACKAGED_APP));
31 EXPECT_EQ(1u, 31 EXPECT_EQ(1u,
32 feature->extension_types()->count(Manifest::TYPE_PLATFORM_APP)); 32 feature->extension_types()->count(Manifest::TYPE_PLATFORM_APP));
33 EXPECT_EQ(1u, feature->extension_types()->count(Manifest::TYPE_HOSTED_APP)); 33 EXPECT_EQ(1u, feature->extension_types()->count(Manifest::TYPE_HOSTED_APP));
(...skipping 21 matching lines...) Expand all
55 55
56 feature = 56 feature =
57 static_cast<SimpleFeature*>(provider->GetFeature("devtools_page")); 57 static_cast<SimpleFeature*>(provider->GetFeature("devtools_page"));
58 ASSERT_TRUE(feature); 58 ASSERT_TRUE(feature);
59 EXPECT_EQ(Feature::NOT_PRESENT, feature->IsAvailableToContext( 59 EXPECT_EQ(Feature::NOT_PRESENT, feature->IsAvailableToContext(
60 extension.get(), Feature::UNSPECIFIED_CONTEXT).result()); 60 extension.get(), Feature::UNSPECIFIED_CONTEXT).result());
61 } 61 }
62 62
63 TEST(BaseFeatureProvider, PermissionFeatures) { 63 TEST(BaseFeatureProvider, PermissionFeatures) {
64 BaseFeatureProvider* provider = 64 BaseFeatureProvider* provider =
65 BaseFeatureProvider::GetPermissionFeatures(); 65 BaseFeatureProvider::GetFeaturesByName("permission");
66 SimpleFeature* feature = 66 SimpleFeature* feature =
67 static_cast<SimpleFeature*>(provider->GetFeature("contextMenus")); 67 static_cast<SimpleFeature*>(provider->GetFeature("contextMenus"));
68 ASSERT_TRUE(feature); 68 ASSERT_TRUE(feature);
69 EXPECT_EQ(3u, feature->extension_types()->size()); 69 EXPECT_EQ(3u, feature->extension_types()->size());
70 EXPECT_EQ(1u, feature->extension_types()->count(Manifest::TYPE_EXTENSION)); 70 EXPECT_EQ(1u, feature->extension_types()->count(Manifest::TYPE_EXTENSION));
71 EXPECT_EQ(1u, 71 EXPECT_EQ(1u,
72 feature->extension_types()->count(Manifest::TYPE_LEGACY_PACKAGED_APP)); 72 feature->extension_types()->count(Manifest::TYPE_LEGACY_PACKAGED_APP));
73 EXPECT_EQ(1u, 73 EXPECT_EQ(1u,
74 feature->extension_types()->count(Manifest::TYPE_PLATFORM_APP)); 74 feature->extension_types()->count(Manifest::TYPE_PLATFORM_APP));
75 75
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 Manifest::TYPE_EXTENSION, 182 Manifest::TYPE_EXTENSION,
183 Feature::UNSPECIFIED_LOCATION, 183 Feature::UNSPECIFIED_LOCATION,
184 Feature::UNSPECIFIED_PLATFORM).result()); 184 Feature::UNSPECIFIED_PLATFORM).result());
185 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( 185 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest(
186 "2", 186 "2",
187 Manifest::TYPE_LEGACY_PACKAGED_APP, 187 Manifest::TYPE_LEGACY_PACKAGED_APP,
188 Feature::UNSPECIFIED_LOCATION, 188 Feature::UNSPECIFIED_LOCATION,
189 Feature::UNSPECIFIED_PLATFORM).result()); 189 Feature::UNSPECIFIED_PLATFORM).result());
190 } 190 }
191 } 191 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698