| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/component_loader.h" | 7 #include "chrome/browser/extensions/component_loader.h" |
| 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/extensions/background_info.h" | 14 #include "chrome/common/extensions/background_info.h" |
| 15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 16 #include "chrome/common/extensions/extension_set.h" | 16 #include "chrome/common/extensions/extension_set.h" |
| 17 #include "chrome/common/extensions/extension_unittest.h" | |
| 18 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/test/base/testing_pref_service_syncable.h" | 18 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 20 #include "components/user_prefs/pref_registry_syncable.h" | 19 #include "components/user_prefs/pref_registry_syncable.h" |
| 21 #include "extensions/common/constants.h" | 20 #include "extensions/common/constants.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 22 |
| 24 namespace extensions { | 23 namespace extensions { |
| 25 | 24 |
| 26 namespace { | 25 namespace { |
| 27 | 26 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 return unloaded_count_; | 65 return unloaded_count_; |
| 67 } | 66 } |
| 68 | 67 |
| 69 void clear_extensions() { | 68 void clear_extensions() { |
| 70 extension_set_.Clear(); | 69 extension_set_.Clear(); |
| 71 } | 70 } |
| 72 }; | 71 }; |
| 73 | 72 |
| 74 } // namespace | 73 } // namespace |
| 75 | 74 |
| 76 class ComponentLoaderTest : public ExtensionTest { | 75 class ComponentLoaderTest : public testing::Test { |
| 77 public: | 76 public: |
| 78 ComponentLoaderTest() | 77 ComponentLoaderTest() |
| 79 // Note: we pass the same pref service here, to stand in for both | 78 // Note: we pass the same pref service here, to stand in for both |
| 80 // user prefs and local state. | 79 // user prefs and local state. |
| 81 : component_loader_(&extension_service_, &prefs_, &local_state_) { | 80 : component_loader_(&extension_service_, &prefs_, &local_state_) { |
| 82 } | 81 } |
| 83 | 82 |
| 84 virtual void SetUp() OVERRIDE { | 83 virtual void SetUp() OVERRIDE { |
| 85 ExtensionTest::SetUp(); | |
| 86 extension_path_ = | 84 extension_path_ = |
| 87 GetBasePath().AppendASCII("good") | 85 GetBasePath().AppendASCII("good") |
| 88 .AppendASCII("Extensions") | 86 .AppendASCII("Extensions") |
| 89 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 87 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
| 90 .AppendASCII("1.0.0.0"); | 88 .AppendASCII("1.0.0.0"); |
| 91 | 89 |
| 92 // Read in the extension manifest. | 90 // Read in the extension manifest. |
| 93 ASSERT_TRUE(file_util::ReadFileToString( | 91 ASSERT_TRUE(file_util::ReadFileToString( |
| 94 extension_path_.Append(kManifestFilename), | 92 extension_path_.Append(kManifestFilename), |
| 95 &manifest_contents_)); | 93 &manifest_contents_)); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 EXPECT_EQ(default_count + 1, extension_service_.extensions()->size()); | 309 EXPECT_EQ(default_count + 1, extension_service_.extensions()->size()); |
| 312 EXPECT_EQ(0u, extension_service_.unloaded_count()); | 310 EXPECT_EQ(0u, extension_service_.unloaded_count()); |
| 313 | 311 |
| 314 // replace loaded component extension. | 312 // replace loaded component extension. |
| 315 component_loader_.AddOrReplace(known_extension); | 313 component_loader_.AddOrReplace(known_extension); |
| 316 EXPECT_EQ(default_count + 1, extension_service_.extensions()->size()); | 314 EXPECT_EQ(default_count + 1, extension_service_.extensions()->size()); |
| 317 EXPECT_EQ(1u, extension_service_.unloaded_count()); | 315 EXPECT_EQ(1u, extension_service_.unloaded_count()); |
| 318 } | 316 } |
| 319 | 317 |
| 320 } // namespace extensions | 318 } // namespace extensions |
| OLD | NEW |