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/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
16 #include "chrome/common/extensions/api/commands/commands_handler.h" | 16 #include "chrome/common/extensions/api/commands/commands_handler.h" |
| 17 #include "chrome/common/extensions/api/commands/commands_handler.h" |
| 18 #include "chrome/common/extensions/background_info.h" |
17 #include "chrome/common/extensions/command.h" | 19 #include "chrome/common/extensions/command.h" |
18 #include "chrome/common/extensions/extension_file_util.h" | 20 #include "chrome/common/extensions/extension_file_util.h" |
19 #include "chrome/common/extensions/extension_manifest_constants.h" | 21 #include "chrome/common/extensions/extension_manifest_constants.h" |
20 #include "chrome/common/extensions/extension_resource.h" | 22 #include "chrome/common/extensions/extension_resource.h" |
21 #include "chrome/common/extensions/features/feature.h" | 23 #include "chrome/common/extensions/features/feature.h" |
22 #include "chrome/common/extensions/manifest.h" | 24 #include "chrome/common/extensions/manifest.h" |
23 #include "chrome/common/extensions/manifest_handler.h" | 25 #include "chrome/common/extensions/manifest_handler.h" |
24 #include "chrome/common/extensions/permissions/api_permission.h" | 26 #include "chrome/common/extensions/permissions/api_permission.h" |
25 #include "chrome/common/extensions/permissions/permission_set.h" | 27 #include "chrome/common/extensions/permissions/permission_set.h" |
26 #include "chrome/common/extensions/permissions/socket_permission.h" | 28 #include "chrome/common/extensions/permissions/socket_permission.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 const std::string& dir, | 96 const std::string& dir, |
95 const std::string& test_file) { | 97 const std::string& test_file) { |
96 return LoadManifest(dir, test_file, Extension::NO_FLAGS); | 98 return LoadManifest(dir, test_file, Extension::NO_FLAGS); |
97 } | 99 } |
98 | 100 |
99 } // namespace | 101 } // namespace |
100 | 102 |
101 class ExtensionTest : public testing::Test { | 103 class ExtensionTest : public testing::Test { |
102 protected: | 104 protected: |
103 virtual void SetUp() OVERRIDE { | 105 virtual void SetUp() OVERRIDE { |
104 ManifestHandler::Register(extension_manifest_keys::kCommands, | 106 std::vector<std::string> background_keys( |
| 107 BackgroundManifestHandler::keys()); |
| 108 linked_ptr<BackgroundManifestHandler> background_handler( |
| 109 new BackgroundManifestHandler); |
| 110 for (size_t i = 0; i < background_keys.size(); ++i) |
| 111 ManifestHandler::Register(background_keys[i], background_handler); |
| 112 ManifestHandler::Register(keys::kCommands, |
105 make_linked_ptr(new CommandsHandler)); | 113 make_linked_ptr(new CommandsHandler)); |
106 } | 114 } |
107 }; | 115 }; |
108 | 116 |
109 // We persist location values in the preferences, so this is a sanity test that | 117 // We persist location values in the preferences, so this is a sanity test that |
110 // someone doesn't accidentally change them. | 118 // someone doesn't accidentally change them. |
111 TEST_F(ExtensionTest, LocationValuesTest) { | 119 TEST_F(ExtensionTest, LocationValuesTest) { |
112 ASSERT_EQ(0, Manifest::INVALID_LOCATION); | 120 ASSERT_EQ(0, Manifest::INVALID_LOCATION); |
113 ASSERT_EQ(1, Manifest::INTERNAL); | 121 ASSERT_EQ(1, Manifest::INTERNAL); |
114 ASSERT_EQ(2, Manifest::EXTERNAL_PREF); | 122 ASSERT_EQ(2, Manifest::EXTERNAL_PREF); |
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 scoped_refptr<Extension> extension( | 1087 scoped_refptr<Extension> extension( |
1080 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), | 1088 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), |
1081 Manifest::INTERNAL, 2, base::FilePath(), | 1089 Manifest::INTERNAL, 2, base::FilePath(), |
1082 Extension::NO_FLAGS)); | 1090 Extension::NO_FLAGS)); |
1083 if (extension) | 1091 if (extension) |
1084 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); | 1092 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); |
1085 } | 1093 } |
1086 #endif // !defined(OS_CHROMEOS) | 1094 #endif // !defined(OS_CHROMEOS) |
1087 | 1095 |
1088 } // namespace extensions | 1096 } // namespace extensions |
OLD | NEW |