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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/json/json_file_value_serializer.h" | 6 #include "base/json/json_file_value_serializer.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
12 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
13 #include "chrome/common/extensions/extension_error_utils.h" | |
14 #include "chrome/common/extensions/extension_manifest_constants.h" | 13 #include "chrome/common/extensions/extension_manifest_constants.h" |
15 #include "chrome/common/extensions/features/feature.h" | 14 #include "chrome/common/extensions/features/feature.h" |
16 #include "chrome/common/extensions/permissions/permission_set.h" | 15 #include "chrome/common/extensions/permissions/permission_set.h" |
17 #include "chrome/common/extensions/permissions/permissions_info.h" | 16 #include "chrome/common/extensions/permissions/permissions_info.h" |
18 #include "chrome/common/extensions/permissions/socket_permission.h" | 17 #include "chrome/common/extensions/permissions/socket_permission.h" |
| 18 #include "extensions/common/error_utils.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 using extensions::Extension; | 21 using extensions::Extension; |
22 | 22 |
23 namespace errors = extension_manifest_errors; | 23 namespace errors = extension_manifest_errors; |
24 namespace keys = extension_manifest_keys; | 24 namespace keys = extension_manifest_keys; |
25 namespace values = extension_manifest_values; | 25 namespace values = extension_manifest_values; |
| 26 |
| 27 namespace extensions { |
| 28 |
26 namespace { | 29 namespace { |
27 | 30 |
28 scoped_refptr<Extension> LoadManifest(const std::string& dir, | 31 scoped_refptr<Extension> LoadManifest(const std::string& dir, |
29 const std::string& test_file, | 32 const std::string& test_file, |
30 int extra_flags) { | 33 int extra_flags) { |
31 FilePath path; | 34 FilePath path; |
32 PathService::Get(chrome::DIR_TEST_DATA, &path); | 35 PathService::Get(chrome::DIR_TEST_DATA, &path); |
33 path = path.AppendASCII("extensions") | 36 path = path.AppendASCII("extensions") |
34 .AppendASCII(dir) | 37 .AppendASCII(dir) |
35 .AppendASCII(test_file); | 38 .AppendASCII(test_file); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 return warnings.size(); | 72 return warnings.size(); |
70 } | 73 } |
71 | 74 |
72 bool Contains(const std::vector<string16>& warnings, | 75 bool Contains(const std::vector<string16>& warnings, |
73 const std::string& warning) { | 76 const std::string& warning) { |
74 return IndexOf(warnings, warning) != warnings.size(); | 77 return IndexOf(warnings, warning) != warnings.size(); |
75 } | 78 } |
76 | 79 |
77 } // namespace | 80 } // namespace |
78 | 81 |
79 namespace extensions { | |
80 | 82 |
81 class PermissionsTest : public testing::Test { | 83 class PermissionsTest : public testing::Test { |
82 }; | 84 }; |
83 | 85 |
84 // Tests GetByID. | 86 // Tests GetByID. |
85 TEST(PermissionsTest, GetByID) { | 87 TEST(PermissionsTest, GetByID) { |
86 PermissionsInfo* info = PermissionsInfo::GetInstance(); | 88 PermissionsInfo* info = PermissionsInfo::GetInstance(); |
87 APIPermissionSet apis = info->GetAll(); | 89 APIPermissionSet apis = info->GetAll(); |
88 for (APIPermissionSet::const_iterator i = apis.begin(); | 90 for (APIPermissionSet::const_iterator i = apis.begin(); |
89 i != apis.end(); ++i) { | 91 i != apis.end(); ++i) { |
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 apis.insert(APIPermission::kWebRequest); | 1343 apis.insert(APIPermission::kWebRequest); |
1342 apis.insert(APIPermission::kFileBrowserHandler); | 1344 apis.insert(APIPermission::kFileBrowserHandler); |
1343 EXPECT_EQ(2U, apis.size()); | 1345 EXPECT_EQ(2U, apis.size()); |
1344 | 1346 |
1345 scoped_refptr<PermissionSet> perm_set; | 1347 scoped_refptr<PermissionSet> perm_set; |
1346 perm_set = new PermissionSet(apis, empty_extent, empty_extent); | 1348 perm_set = new PermissionSet(apis, empty_extent, empty_extent); |
1347 EXPECT_EQ(4U, perm_set->apis().size()); | 1349 EXPECT_EQ(4U, perm_set->apis().size()); |
1348 } | 1350 } |
1349 | 1351 |
1350 } // namespace extensions | 1352 } // namespace extensions |
OLD | NEW |