OLD | NEW |
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/simple_feature_provider.h" | 5 #include "chrome/common/extensions/features/simple_feature_provider.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 using extensions::Extension; | 9 using extensions::Extension; |
10 using extensions::Feature; | 10 using extensions::Feature; |
11 using extensions::SimpleFeatureProvider; | 11 using extensions::SimpleFeatureProvider; |
12 | 12 |
13 TEST(SimpleFeatureProvider, ManifestFeatures) { | 13 TEST(SimpleFeatureProvider, ManifestFeatures) { |
14 SimpleFeatureProvider* provider = | 14 SimpleFeatureProvider* provider = |
15 SimpleFeatureProvider::GetManifestFeatures(); | 15 SimpleFeatureProvider::GetManifestFeatures(); |
16 Feature* feature = provider->GetFeature("description"); | 16 Feature* feature = provider->GetFeature("description"); |
17 ASSERT_TRUE(feature); | 17 ASSERT_TRUE(feature); |
18 EXPECT_EQ(5u, feature->extension_types()->size()); | 18 EXPECT_EQ(5u, feature->extension_types()->size()); |
19 EXPECT_EQ(1u, feature->extension_types()->count(Extension::TYPE_EXTENSION)); | 19 EXPECT_EQ(1u, feature->extension_types()->count(Extension::TYPE_EXTENSION)); |
20 EXPECT_EQ(1u, | 20 EXPECT_EQ(1u, |
21 feature->extension_types()->count(Extension::TYPE_PACKAGED_APP)); | 21 feature->extension_types()->count(Extension::TYPE_LEGACY_PACKAGED_APP)); |
22 EXPECT_EQ(1u, | 22 EXPECT_EQ(1u, |
23 feature->extension_types()->count(Extension::TYPE_PLATFORM_APP)); | 23 feature->extension_types()->count(Extension::TYPE_PLATFORM_APP)); |
24 EXPECT_EQ(1u, feature->extension_types()->count(Extension::TYPE_HOSTED_APP)); | 24 EXPECT_EQ(1u, feature->extension_types()->count(Extension::TYPE_HOSTED_APP)); |
25 EXPECT_EQ(1u, feature->extension_types()->count(Extension::TYPE_THEME)); | 25 EXPECT_EQ(1u, feature->extension_types()->count(Extension::TYPE_THEME)); |
26 | 26 |
27 DictionaryValue manifest; | 27 DictionaryValue manifest; |
28 manifest.SetString("name", "test extension"); | 28 manifest.SetString("name", "test extension"); |
29 manifest.SetString("version", "1"); | 29 manifest.SetString("version", "1"); |
30 manifest.SetString("description", "hello there"); | 30 manifest.SetString("description", "hello there"); |
31 | 31 |
(...skipping 18 matching lines...) Expand all Loading... |
50 } | 50 } |
51 | 51 |
52 TEST(SimpleFeatureProvider, PermissionFeatures) { | 52 TEST(SimpleFeatureProvider, PermissionFeatures) { |
53 SimpleFeatureProvider* provider = | 53 SimpleFeatureProvider* provider = |
54 SimpleFeatureProvider::GetPermissionFeatures(); | 54 SimpleFeatureProvider::GetPermissionFeatures(); |
55 Feature* feature = provider->GetFeature("contextMenus"); | 55 Feature* feature = provider->GetFeature("contextMenus"); |
56 ASSERT_TRUE(feature); | 56 ASSERT_TRUE(feature); |
57 EXPECT_EQ(3u, feature->extension_types()->size()); | 57 EXPECT_EQ(3u, feature->extension_types()->size()); |
58 EXPECT_EQ(1u, feature->extension_types()->count(Extension::TYPE_EXTENSION)); | 58 EXPECT_EQ(1u, feature->extension_types()->count(Extension::TYPE_EXTENSION)); |
59 EXPECT_EQ(1u, | 59 EXPECT_EQ(1u, |
60 feature->extension_types()->count(Extension::TYPE_PACKAGED_APP)); | 60 feature->extension_types()->count(Extension::TYPE_LEGACY_PACKAGED_APP)); |
61 EXPECT_EQ(1u, | 61 EXPECT_EQ(1u, |
62 feature->extension_types()->count(Extension::TYPE_PLATFORM_APP)); | 62 feature->extension_types()->count(Extension::TYPE_PLATFORM_APP)); |
63 | 63 |
64 DictionaryValue manifest; | 64 DictionaryValue manifest; |
65 manifest.SetString("name", "test extension"); | 65 manifest.SetString("name", "test extension"); |
66 manifest.SetString("version", "1"); | 66 manifest.SetString("version", "1"); |
67 ListValue* permissions = new ListValue(); | 67 ListValue* permissions = new ListValue(); |
68 manifest.Set("permissions", permissions); | 68 manifest.Set("permissions", permissions); |
69 permissions->Append(Value::CreateStringValue("contextMenus")); | 69 permissions->Append(Value::CreateStringValue("contextMenus")); |
70 | 70 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 EXPECT_TRUE(provider->GetFeature("feature1")); | 115 EXPECT_TRUE(provider->GetFeature("feature1")); |
116 | 116 |
117 // feature2 won't validate because of the presence of "contexts". | 117 // feature2 won't validate because of the presence of "contexts". |
118 EXPECT_FALSE(provider->GetFeature("feature2")); | 118 EXPECT_FALSE(provider->GetFeature("feature2")); |
119 | 119 |
120 // If we remove it, it works. | 120 // If we remove it, it works. |
121 feature2->Remove("contexts", NULL); | 121 feature2->Remove("contexts", NULL); |
122 provider.reset(new SimpleFeatureProvider(value.get(), NULL)); | 122 provider.reset(new SimpleFeatureProvider(value.get(), NULL)); |
123 EXPECT_TRUE(provider->GetFeature("feature2")); | 123 EXPECT_TRUE(provider->GetFeature("feature2")); |
124 } | 124 } |
OLD | NEW |