| 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/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "chrome/test/base/testing_pref_service_syncable.h" | 18 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 19 #include "components/user_prefs/pref_registry_syncable.h" | 19 #include "components/user_prefs/pref_registry_syncable.h" |
| 20 #include "extensions/common/constants.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 22 |
| 22 using extensions::Extension; | 23 using extensions::Extension; |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 class MockExtensionService : public TestExtensionService { | 27 class MockExtensionService : public TestExtensionService { |
| 27 private: | 28 private: |
| 28 bool ready_; | 29 bool ready_; |
| 29 size_t unloaded_count_; | 30 size_t unloaded_count_; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 (new BackgroundManifestHandler)->Register(); | 86 (new BackgroundManifestHandler)->Register(); |
| 86 | 87 |
| 87 extension_path_ = | 88 extension_path_ = |
| 88 GetBasePath().AppendASCII("good") | 89 GetBasePath().AppendASCII("good") |
| 89 .AppendASCII("Extensions") | 90 .AppendASCII("Extensions") |
| 90 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 91 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
| 91 .AppendASCII("1.0.0.0"); | 92 .AppendASCII("1.0.0.0"); |
| 92 | 93 |
| 93 // Read in the extension manifest. | 94 // Read in the extension manifest. |
| 94 ASSERT_TRUE(file_util::ReadFileToString( | 95 ASSERT_TRUE(file_util::ReadFileToString( |
| 95 extension_path_.Append(Extension::kManifestFilename), | 96 extension_path_.Append(kManifestFilename), |
| 96 &manifest_contents_)); | 97 &manifest_contents_)); |
| 97 | 98 |
| 98 // Register the user prefs that ComponentLoader will read. | 99 // Register the user prefs that ComponentLoader will read. |
| 99 prefs_.registry()->RegisterStringPref( | 100 prefs_.registry()->RegisterStringPref( |
| 100 prefs::kEnterpriseWebStoreURL, | 101 prefs::kEnterpriseWebStoreURL, |
| 101 std::string(), | 102 std::string(), |
| 102 PrefRegistrySyncable::UNSYNCABLE_PREF); | 103 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 103 prefs_.registry()->RegisterStringPref( | 104 prefs_.registry()->RegisterStringPref( |
| 104 prefs::kEnterpriseWebStoreName, | 105 prefs::kEnterpriseWebStoreName, |
| 105 std::string(), | 106 std::string(), |
| 106 PrefRegistrySyncable::UNSYNCABLE_PREF); | 107 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 EXPECT_EQ(default_count + 1, extension_service_.extensions()->size()); | 313 EXPECT_EQ(default_count + 1, extension_service_.extensions()->size()); |
| 313 EXPECT_EQ(0u, extension_service_.unloaded_count()); | 314 EXPECT_EQ(0u, extension_service_.unloaded_count()); |
| 314 | 315 |
| 315 // replace loaded component extension. | 316 // replace loaded component extension. |
| 316 component_loader_.AddOrReplace(known_extension); | 317 component_loader_.AddOrReplace(known_extension); |
| 317 EXPECT_EQ(default_count + 1, extension_service_.extensions()->size()); | 318 EXPECT_EQ(default_count + 1, extension_service_.extensions()->size()); |
| 318 EXPECT_EQ(1u, extension_service_.unloaded_count()); | 319 EXPECT_EQ(1u, extension_service_.unloaded_count()); |
| 319 } | 320 } |
| 320 | 321 |
| 321 } // namespace extensions | 322 } // namespace extensions |
| OLD | NEW |