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/browser/extensions/component_loader.h" | 5 #include "chrome/browser/extensions/component_loader.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
12 #include "chrome/browser/extensions/test_extension_service.h" | 12 #include "chrome/browser/extensions/test_extension_service.h" |
13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
15 #include "chrome/test/base/testing_pref_service_syncable.h" | 15 #include "chrome/test/base/testing_pref_service_syncable.h" |
16 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
17 #include "components/user_prefs/pref_registry_syncable.h" | 17 #include "components/user_prefs/pref_registry_syncable.h" |
| 18 #include "content/public/test/test_browser_thread_bundle.h" |
18 #include "extensions/common/constants.h" | 19 #include "extensions/common/constants.h" |
19 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
20 #include "extensions/common/extension_set.h" | 21 #include "extensions/common/extension_set.h" |
21 #include "extensions/common/manifest_handlers/background_info.h" | 22 #include "extensions/common/manifest_handlers/background_info.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 | 24 |
24 namespace extensions { | 25 namespace extensions { |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 TestingPrefServiceSimple local_state_; | 115 TestingPrefServiceSimple local_state_; |
115 TestingProfile profile_; | 116 TestingProfile profile_; |
116 ComponentLoader component_loader_; | 117 ComponentLoader component_loader_; |
117 | 118 |
118 // The root directory of the text extension. | 119 // The root directory of the text extension. |
119 base::FilePath extension_path_; | 120 base::FilePath extension_path_; |
120 | 121 |
121 // The contents of the text extension's manifest file. | 122 // The contents of the text extension's manifest file. |
122 std::string manifest_contents_; | 123 std::string manifest_contents_; |
123 | 124 |
| 125 content::TestBrowserThreadBundle thread_bundle_; |
| 126 |
124 base::FilePath GetBasePath() { | 127 base::FilePath GetBasePath() { |
125 base::FilePath test_data_dir; | 128 base::FilePath test_data_dir; |
126 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); | 129 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); |
127 return test_data_dir.AppendASCII("extensions"); | 130 return test_data_dir.AppendASCII("extensions"); |
128 } | 131 } |
129 }; | 132 }; |
130 | 133 |
131 TEST_F(ComponentLoaderTest, ParseManifest) { | 134 TEST_F(ComponentLoaderTest, ParseManifest) { |
132 scoped_ptr<base::DictionaryValue> manifest; | 135 scoped_ptr<base::DictionaryValue> manifest; |
133 | 136 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 component_loader_.AddOrReplace(known_extension); | 274 component_loader_.AddOrReplace(known_extension); |
272 EXPECT_EQ(default_count + 1, extension_service_.extensions()->size()); | 275 EXPECT_EQ(default_count + 1, extension_service_.extensions()->size()); |
273 EXPECT_EQ(1u, extension_service_.unloaded_count()); | 276 EXPECT_EQ(1u, extension_service_.unloaded_count()); |
274 | 277 |
275 // Add an invalid component extension. | 278 // Add an invalid component extension. |
276 std::string extension_id = component_loader_.AddOrReplace(invalid_extension); | 279 std::string extension_id = component_loader_.AddOrReplace(invalid_extension); |
277 EXPECT_TRUE(extension_id.empty()); | 280 EXPECT_TRUE(extension_id.empty()); |
278 } | 281 } |
279 | 282 |
280 } // namespace extensions | 283 } // namespace extensions |
OLD | NEW |