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

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: fix merge conflicts 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/extension_unittest.h" 7 #include "chrome/common/extensions/extension_unittest.h"
8 #include "chrome/common/extensions/features/permission_feature.h" 8 #include "chrome/common/extensions/features/permission_feature.h"
9 #include "chrome/common/extensions/value_builder.h" 9 #include "chrome/common/extensions/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 13
14 namespace extensions { 14 namespace extensions {
15 15
16 class BaseFeatureProviderTest : public ExtensionTest { 16 class BaseFeatureProviderTest : public ExtensionTest {
17 }; 17 };
18 18
19 TEST_F(BaseFeatureProviderTest, ManifestFeatures) { 19 TEST_F(BaseFeatureProviderTest, ManifestFeatures) {
20 BaseFeatureProvider* provider = 20 FeatureProvider* provider = BaseFeatureProvider::GetByName("manifest");
21 BaseFeatureProvider::GetManifestFeatures();
22 SimpleFeature* feature = 21 SimpleFeature* feature =
23 static_cast<SimpleFeature*>(provider->GetFeature("description")); 22 static_cast<SimpleFeature*>(provider->GetFeature("description"));
24 ASSERT_TRUE(feature); 23 ASSERT_TRUE(feature);
25 EXPECT_EQ(5u, feature->extension_types()->size()); 24 EXPECT_EQ(5u, feature->extension_types()->size());
26 EXPECT_EQ(1u, feature->extension_types()->count(Manifest::TYPE_EXTENSION)); 25 EXPECT_EQ(1u, feature->extension_types()->count(Manifest::TYPE_EXTENSION));
27 EXPECT_EQ(1u, 26 EXPECT_EQ(1u,
28 feature->extension_types()->count(Manifest::TYPE_LEGACY_PACKAGED_APP)); 27 feature->extension_types()->count(Manifest::TYPE_LEGACY_PACKAGED_APP));
29 EXPECT_EQ(1u, 28 EXPECT_EQ(1u,
30 feature->extension_types()->count(Manifest::TYPE_PLATFORM_APP)); 29 feature->extension_types()->count(Manifest::TYPE_PLATFORM_APP));
31 EXPECT_EQ(1u, feature->extension_types()->count(Manifest::TYPE_HOSTED_APP)); 30 EXPECT_EQ(1u, feature->extension_types()->count(Manifest::TYPE_HOSTED_APP));
(...skipping 20 matching lines...) Expand all
52 extension.get(), Feature::UNSPECIFIED_CONTEXT).result()); 51 extension.get(), Feature::UNSPECIFIED_CONTEXT).result());
53 52
54 feature = 53 feature =
55 static_cast<SimpleFeature*>(provider->GetFeature("devtools_page")); 54 static_cast<SimpleFeature*>(provider->GetFeature("devtools_page"));
56 ASSERT_TRUE(feature); 55 ASSERT_TRUE(feature);
57 EXPECT_EQ(Feature::NOT_PRESENT, feature->IsAvailableToContext( 56 EXPECT_EQ(Feature::NOT_PRESENT, feature->IsAvailableToContext(
58 extension.get(), Feature::UNSPECIFIED_CONTEXT).result()); 57 extension.get(), Feature::UNSPECIFIED_CONTEXT).result());
59 } 58 }
60 59
61 TEST_F(BaseFeatureProviderTest, PermissionFeatures) { 60 TEST_F(BaseFeatureProviderTest, PermissionFeatures) {
62 BaseFeatureProvider* provider = 61 FeatureProvider* provider = BaseFeatureProvider::GetByName("permission");
63 BaseFeatureProvider::GetPermissionFeatures();
64 SimpleFeature* feature = 62 SimpleFeature* feature =
65 static_cast<SimpleFeature*>(provider->GetFeature("contextMenus")); 63 static_cast<SimpleFeature*>(provider->GetFeature("contextMenus"));
66 ASSERT_TRUE(feature); 64 ASSERT_TRUE(feature);
67 EXPECT_EQ(3u, feature->extension_types()->size()); 65 EXPECT_EQ(3u, feature->extension_types()->size());
68 EXPECT_EQ(1u, feature->extension_types()->count(Manifest::TYPE_EXTENSION)); 66 EXPECT_EQ(1u, feature->extension_types()->count(Manifest::TYPE_EXTENSION));
69 EXPECT_EQ(1u, 67 EXPECT_EQ(1u,
70 feature->extension_types()->count(Manifest::TYPE_LEGACY_PACKAGED_APP)); 68 feature->extension_types()->count(Manifest::TYPE_LEGACY_PACKAGED_APP));
71 EXPECT_EQ(1u, 69 EXPECT_EQ(1u,
72 feature->extension_types()->count(Manifest::TYPE_PLATFORM_APP)); 70 feature->extension_types()->count(Manifest::TYPE_PLATFORM_APP));
73 71
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 Feature::UNSPECIFIED_PLATFORM).result()); 180 Feature::UNSPECIFIED_PLATFORM).result());
183 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest( 181 EXPECT_NE(Feature::IS_AVAILABLE, feature->IsAvailableToManifest(
184 "2", 182 "2",
185 Manifest::TYPE_LEGACY_PACKAGED_APP, 183 Manifest::TYPE_LEGACY_PACKAGED_APP,
186 Feature::UNSPECIFIED_LOCATION, 184 Feature::UNSPECIFIED_LOCATION,
187 Feature::UNSPECIFIED_PLATFORM).result()); 185 Feature::UNSPECIFIED_PLATFORM).result());
188 } 186 }
189 } 187 }
190 188
191 } // namespace extensions 189 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/features/base_feature_provider.cc ('k') | chrome/common/extensions/features/feature_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698