Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
|
Aaron Boodman
2011/10/28 22:21:58
It would be nice to pull these tests out in unpack
Yoyo Zhou
2011/10/31 21:58:15
I was considering doing this, though at the time i
| |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
| 15 #include "base/json/json_reader.h" | 15 #include "base/json/json_reader.h" |
| 16 #include "base/json/json_value_serializer.h" | 16 #include "base/json/json_value_serializer.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
| 19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 20 #include "base/scoped_temp_dir.h" | 20 #include "base/scoped_temp_dir.h" |
| 21 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
| 22 #include "base/string16.h" | 22 #include "base/string16.h" |
| 23 #include "base/string_number_conversions.h" | 23 #include "base/string_number_conversions.h" |
| 24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
| 25 #include "base/utf_string_conversions.h" | 25 #include "base/utf_string_conversions.h" |
| 26 #include "base/version.h" | 26 #include "base/version.h" |
| 27 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
| 28 #include "chrome/browser/extensions/crx_installer.h" | 28 #include "chrome/browser/extensions/crx_installer.h" |
| 29 #include "chrome/browser/extensions/component_loader.h" | |
| 29 #include "chrome/browser/extensions/extension_creator.h" | 30 #include "chrome/browser/extensions/extension_creator.h" |
| 30 #include "chrome/browser/extensions/extension_error_reporter.h" | 31 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 31 #include "chrome/browser/extensions/extension_service.h" | 32 #include "chrome/browser/extensions/extension_service.h" |
| 32 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 33 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 33 #include "chrome/browser/extensions/extension_sync_data.h" | 34 #include "chrome/browser/extensions/extension_sync_data.h" |
| 34 #include "chrome/browser/extensions/extension_updater.h" | 35 #include "chrome/browser/extensions/extension_updater.h" |
| 35 #include "chrome/browser/extensions/external_extension_provider_impl.h" | 36 #include "chrome/browser/extensions/external_extension_provider_impl.h" |
| 36 #include "chrome/browser/extensions/external_extension_provider_interface.h" | 37 #include "chrome/browser/extensions/external_extension_provider_interface.h" |
| 37 #include "chrome/browser/extensions/external_pref_extension_loader.h" | 38 #include "chrome/browser/extensions/external_pref_extension_loader.h" |
| 39 #include "chrome/browser/extensions/installed_extension_loader.h" | |
| 38 #include "chrome/browser/extensions/pack_extension_job.cc" | 40 #include "chrome/browser/extensions/pack_extension_job.cc" |
| 39 #include "chrome/browser/extensions/pending_extension_info.h" | 41 #include "chrome/browser/extensions/pending_extension_info.h" |
| 40 #include "chrome/browser/extensions/pending_extension_manager.h" | 42 #include "chrome/browser/extensions/pending_extension_manager.h" |
| 43 #include "chrome/browser/extensions/unpacked_installer.h" | |
| 41 #include "chrome/browser/prefs/browser_prefs.h" | 44 #include "chrome/browser/prefs/browser_prefs.h" |
| 42 #include "chrome/browser/prefs/pref_service_mock_builder.h" | 45 #include "chrome/browser/prefs/pref_service_mock_builder.h" |
| 43 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 46 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 44 #include "chrome/browser/sync/protocol/app_specifics.pb.h" | 47 #include "chrome/browser/sync/protocol/app_specifics.pb.h" |
| 45 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" | 48 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" |
| 46 #include "chrome/common/chrome_notification_types.h" | 49 #include "chrome/common/chrome_notification_types.h" |
| 47 #include "chrome/common/chrome_paths.h" | 50 #include "chrome/common/chrome_paths.h" |
| 48 #include "chrome/common/chrome_switches.h" | 51 #include "chrome/common/chrome_switches.h" |
| 49 #include "chrome/common/extensions/extension.h" | 52 #include "chrome/common/extensions/extension.h" |
| 50 #include "chrome/common/extensions/extension_constants.h" | 53 #include "chrome/common/extensions/extension_constants.h" |
| (...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1754 InstallCrx(path, false); | 1757 InstallCrx(path, false); |
| 1755 ValidatePrefKeyCount(pref_count); | 1758 ValidatePrefKeyCount(pref_count); |
| 1756 } | 1759 } |
| 1757 | 1760 |
| 1758 TEST_F(ExtensionServiceTest, LoadLocalizedTheme) { | 1761 TEST_F(ExtensionServiceTest, LoadLocalizedTheme) { |
| 1759 // Load. | 1762 // Load. |
| 1760 InitializeEmptyExtensionService(); | 1763 InitializeEmptyExtensionService(); |
| 1761 FilePath extension_path = data_dir_ | 1764 FilePath extension_path = data_dir_ |
| 1762 .AppendASCII("theme_i18n"); | 1765 .AppendASCII("theme_i18n"); |
| 1763 | 1766 |
| 1764 service_->LoadExtension(extension_path); | 1767 service_->MakeUnpackedInstaller()->Load(extension_path); |
| 1765 loop_.RunAllPending(); | 1768 loop_.RunAllPending(); |
| 1766 EXPECT_EQ(0u, GetErrors().size()); | 1769 EXPECT_EQ(0u, GetErrors().size()); |
| 1767 ASSERT_EQ(1u, loaded_.size()); | 1770 ASSERT_EQ(1u, loaded_.size()); |
| 1768 EXPECT_EQ(1u, service_->extensions()->size()); | 1771 EXPECT_EQ(1u, service_->extensions()->size()); |
| 1769 EXPECT_EQ("name", service_->extensions()->at(0)->name()); | 1772 EXPECT_EQ("name", service_->extensions()->at(0)->name()); |
| 1770 EXPECT_EQ("description", service_->extensions()->at(0)->description()); | 1773 EXPECT_EQ("description", service_->extensions()->at(0)->description()); |
| 1771 } | 1774 } |
| 1772 | 1775 |
| 1773 TEST_F(ExtensionServiceTest, InstallLocalizedTheme) { | 1776 TEST_F(ExtensionServiceTest, InstallLocalizedTheme) { |
| 1774 InitializeEmptyExtensionService(); | 1777 InitializeEmptyExtensionService(); |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2170 ASSERT_FALSE(file_util::PathExists(manifest_path)); | 2173 ASSERT_FALSE(file_util::PathExists(manifest_path)); |
| 2171 | 2174 |
| 2172 // Start with version 2.0. | 2175 // Start with version 2.0. |
| 2173 DictionaryValue manifest; | 2176 DictionaryValue manifest; |
| 2174 manifest.SetString("version", "2.0"); | 2177 manifest.SetString("version", "2.0"); |
| 2175 manifest.SetString("name", "LOAD Downgrade Test"); | 2178 manifest.SetString("name", "LOAD Downgrade Test"); |
| 2176 | 2179 |
| 2177 JSONFileValueSerializer serializer(manifest_path); | 2180 JSONFileValueSerializer serializer(manifest_path); |
| 2178 ASSERT_TRUE(serializer.Serialize(manifest)); | 2181 ASSERT_TRUE(serializer.Serialize(manifest)); |
| 2179 | 2182 |
| 2180 service_->LoadExtension(extension_path); | 2183 service_->MakeUnpackedInstaller()->Load(extension_path); |
| 2181 loop_.RunAllPending(); | 2184 loop_.RunAllPending(); |
| 2182 | 2185 |
| 2183 EXPECT_EQ(0u, GetErrors().size()); | 2186 EXPECT_EQ(0u, GetErrors().size()); |
| 2184 ASSERT_EQ(1u, loaded_.size()); | 2187 ASSERT_EQ(1u, loaded_.size()); |
| 2185 EXPECT_EQ(Extension::LOAD, loaded_[0]->location()); | 2188 EXPECT_EQ(Extension::LOAD, loaded_[0]->location()); |
| 2186 EXPECT_EQ(1u, service_->extensions()->size()); | 2189 EXPECT_EQ(1u, service_->extensions()->size()); |
| 2187 EXPECT_EQ("2.0", loaded_[0]->VersionString()); | 2190 EXPECT_EQ("2.0", loaded_[0]->VersionString()); |
| 2188 | 2191 |
| 2189 // Now set the version number to 1.0, reload the extensions and verify that | 2192 // Now set the version number to 1.0, reload the extensions and verify that |
| 2190 // the downgrade was accepted. | 2193 // the downgrade was accepted. |
| 2191 manifest.SetString("version", "1.0"); | 2194 manifest.SetString("version", "1.0"); |
| 2192 ASSERT_TRUE(serializer.Serialize(manifest)); | 2195 ASSERT_TRUE(serializer.Serialize(manifest)); |
| 2193 | 2196 |
| 2194 service_->LoadExtension(extension_path); | 2197 service_->MakeUnpackedInstaller()->Load(extension_path); |
| 2195 loop_.RunAllPending(); | 2198 loop_.RunAllPending(); |
| 2196 | 2199 |
| 2197 EXPECT_EQ(0u, GetErrors().size()); | 2200 EXPECT_EQ(0u, GetErrors().size()); |
| 2198 ASSERT_EQ(1u, loaded_.size()); | 2201 ASSERT_EQ(1u, loaded_.size()); |
| 2199 EXPECT_EQ(Extension::LOAD, loaded_[0]->location()); | 2202 EXPECT_EQ(Extension::LOAD, loaded_[0]->location()); |
| 2200 EXPECT_EQ(1u, service_->extensions()->size()); | 2203 EXPECT_EQ(1u, service_->extensions()->size()); |
| 2201 EXPECT_EQ("1.0", loaded_[0]->VersionString()); | 2204 EXPECT_EQ("1.0", loaded_[0]->VersionString()); |
| 2202 } | 2205 } |
| 2203 | 2206 |
| 2204 namespace { | 2207 namespace { |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2978 | 2981 |
| 2979 // Tests loading single extensions (like --load-extension) | 2982 // Tests loading single extensions (like --load-extension) |
| 2980 TEST_F(ExtensionServiceTest, LoadExtension) { | 2983 TEST_F(ExtensionServiceTest, LoadExtension) { |
| 2981 InitializeEmptyExtensionService(); | 2984 InitializeEmptyExtensionService(); |
| 2982 | 2985 |
| 2983 FilePath ext1 = data_dir_ | 2986 FilePath ext1 = data_dir_ |
| 2984 .AppendASCII("good") | 2987 .AppendASCII("good") |
| 2985 .AppendASCII("Extensions") | 2988 .AppendASCII("Extensions") |
| 2986 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 2989 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
| 2987 .AppendASCII("1.0.0.0"); | 2990 .AppendASCII("1.0.0.0"); |
| 2988 service_->LoadExtension(ext1); | 2991 service_->MakeUnpackedInstaller()->Load(ext1); |
| 2989 loop_.RunAllPending(); | 2992 loop_.RunAllPending(); |
| 2990 EXPECT_EQ(0u, GetErrors().size()); | 2993 EXPECT_EQ(0u, GetErrors().size()); |
| 2991 ASSERT_EQ(1u, loaded_.size()); | 2994 ASSERT_EQ(1u, loaded_.size()); |
| 2992 EXPECT_EQ(Extension::LOAD, loaded_[0]->location()); | 2995 EXPECT_EQ(Extension::LOAD, loaded_[0]->location()); |
| 2993 EXPECT_EQ(1u, service_->extensions()->size()); | 2996 EXPECT_EQ(1u, service_->extensions()->size()); |
| 2994 | 2997 |
| 2995 ValidatePrefKeyCount(1); | 2998 ValidatePrefKeyCount(1); |
| 2996 | 2999 |
| 2997 FilePath no_manifest = data_dir_ | 3000 FilePath no_manifest = data_dir_ |
| 2998 .AppendASCII("bad") | 3001 .AppendASCII("bad") |
| 2999 // .AppendASCII("Extensions") | 3002 // .AppendASCII("Extensions") |
| 3000 .AppendASCII("cccccccccccccccccccccccccccccccc") | 3003 .AppendASCII("cccccccccccccccccccccccccccccccc") |
| 3001 .AppendASCII("1"); | 3004 .AppendASCII("1"); |
| 3002 service_->LoadExtension(no_manifest); | 3005 service_->MakeUnpackedInstaller()->Load(no_manifest); |
| 3003 loop_.RunAllPending(); | 3006 loop_.RunAllPending(); |
| 3004 EXPECT_EQ(1u, GetErrors().size()); | 3007 EXPECT_EQ(1u, GetErrors().size()); |
| 3005 ASSERT_EQ(1u, loaded_.size()); | 3008 ASSERT_EQ(1u, loaded_.size()); |
| 3006 EXPECT_EQ(1u, service_->extensions()->size()); | 3009 EXPECT_EQ(1u, service_->extensions()->size()); |
| 3007 | 3010 |
| 3008 // Test uninstall. | 3011 // Test uninstall. |
| 3009 std::string id = loaded_[0]->id(); | 3012 std::string id = loaded_[0]->id(); |
| 3010 EXPECT_FALSE(unloaded_id_.length()); | 3013 EXPECT_FALSE(unloaded_id_.length()); |
| 3011 service_->UninstallExtension(id, false, NULL); | 3014 service_->UninstallExtension(id, false, NULL); |
| 3012 loop_.RunAllPending(); | 3015 loop_.RunAllPending(); |
| 3013 EXPECT_EQ(id, unloaded_id_); | 3016 EXPECT_EQ(id, unloaded_id_); |
| 3014 ASSERT_EQ(0u, loaded_.size()); | 3017 ASSERT_EQ(0u, loaded_.size()); |
| 3015 EXPECT_EQ(0u, service_->extensions()->size()); | 3018 EXPECT_EQ(0u, service_->extensions()->size()); |
| 3016 } | 3019 } |
| 3017 | 3020 |
| 3018 // Tests that we generate IDs when they are not specified in the manifest for | 3021 // Tests that we generate IDs when they are not specified in the manifest for |
| 3019 // --load-extension. | 3022 // --load-extension. |
| 3020 TEST_F(ExtensionServiceTest, GenerateID) { | 3023 TEST_F(ExtensionServiceTest, GenerateID) { |
| 3021 InitializeEmptyExtensionService(); | 3024 InitializeEmptyExtensionService(); |
| 3022 | 3025 |
| 3023 | 3026 |
| 3024 FilePath no_id_ext = data_dir_.AppendASCII("no_id"); | 3027 FilePath no_id_ext = data_dir_.AppendASCII("no_id"); |
| 3025 service_->LoadExtension(no_id_ext); | 3028 service_->MakeUnpackedInstaller()->Load(no_id_ext); |
| 3026 loop_.RunAllPending(); | 3029 loop_.RunAllPending(); |
| 3027 EXPECT_EQ(0u, GetErrors().size()); | 3030 EXPECT_EQ(0u, GetErrors().size()); |
| 3028 ASSERT_EQ(1u, loaded_.size()); | 3031 ASSERT_EQ(1u, loaded_.size()); |
| 3029 ASSERT_TRUE(Extension::IdIsValid(loaded_[0]->id())); | 3032 ASSERT_TRUE(Extension::IdIsValid(loaded_[0]->id())); |
| 3030 EXPECT_EQ(loaded_[0]->location(), Extension::LOAD); | 3033 EXPECT_EQ(loaded_[0]->location(), Extension::LOAD); |
| 3031 | 3034 |
| 3032 ValidatePrefKeyCount(1); | 3035 ValidatePrefKeyCount(1); |
| 3033 | 3036 |
| 3034 std::string previous_id = loaded_[0]->id(); | 3037 std::string previous_id = loaded_[0]->id(); |
| 3035 | 3038 |
| 3036 // If we reload the same path, we should get the same extension ID. | 3039 // If we reload the same path, we should get the same extension ID. |
| 3037 service_->LoadExtension(no_id_ext); | 3040 service_->MakeUnpackedInstaller()->Load(no_id_ext); |
| 3038 loop_.RunAllPending(); | 3041 loop_.RunAllPending(); |
| 3039 ASSERT_EQ(1u, loaded_.size()); | 3042 ASSERT_EQ(1u, loaded_.size()); |
| 3040 ASSERT_EQ(previous_id, loaded_[0]->id()); | 3043 ASSERT_EQ(previous_id, loaded_[0]->id()); |
| 3041 } | 3044 } |
| 3042 | 3045 |
| 3043 void ExtensionServiceTest::TestExternalProvider( | 3046 void ExtensionServiceTest::TestExternalProvider( |
| 3044 MockExtensionProvider* provider, Extension::Location location) { | 3047 MockExtensionProvider* provider, Extension::Location location) { |
| 3045 // Verify that starting with no providers loads no extensions. | 3048 // Verify that starting with no providers loads no extensions. |
| 3046 service_->Init(); | 3049 service_->Init(); |
| 3047 loop_.RunAllPending(); | 3050 loop_.RunAllPending(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3157 loaded_.clear(); | 3160 loaded_.clear(); |
| 3158 service_->UninstallExtension(id, false, NULL); | 3161 service_->UninstallExtension(id, false, NULL); |
| 3159 loop_.RunAllPending(); | 3162 loop_.RunAllPending(); |
| 3160 ASSERT_EQ(0u, loaded_.size()); | 3163 ASSERT_EQ(0u, loaded_.size()); |
| 3161 | 3164 |
| 3162 // Then remove the extension from the extension provider. | 3165 // Then remove the extension from the extension provider. |
| 3163 provider->RemoveExtension(good_crx); | 3166 provider->RemoveExtension(good_crx); |
| 3164 | 3167 |
| 3165 // Should still be at 0. | 3168 // Should still be at 0. |
| 3166 loaded_.clear(); | 3169 loaded_.clear(); |
| 3167 service_->LoadAllExtensions(); | 3170 service_->MakeInstalledExtensionLoader()->LoadAllExtensions(); |
| 3168 loop_.RunAllPending(); | 3171 loop_.RunAllPending(); |
| 3169 ASSERT_EQ(0u, loaded_.size()); | 3172 ASSERT_EQ(0u, loaded_.size()); |
| 3170 ValidatePrefKeyCount(1); | 3173 ValidatePrefKeyCount(1); |
| 3171 | 3174 |
| 3172 EXPECT_EQ(5, provider->visit_count()); | 3175 EXPECT_EQ(5, provider->visit_count()); |
| 3173 } else { | 3176 } else { |
| 3174 EXPECT_EQ(2, provider->visit_count()); | 3177 EXPECT_EQ(2, provider->visit_count()); |
| 3175 } | 3178 } |
| 3176 } | 3179 } |
| 3177 | 3180 |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3608 .AppendASCII("1.0"); | 3611 .AppendASCII("1.0"); |
| 3609 | 3612 |
| 3610 // The old permission name for unlimited quota was "unlimited_storage", but | 3613 // The old permission name for unlimited quota was "unlimited_storage", but |
| 3611 // we changed it to "unlimitedStorage". This tests both versions. | 3614 // we changed it to "unlimitedStorage". This tests both versions. |
| 3612 FilePath unlimited_quota_ext = | 3615 FilePath unlimited_quota_ext = |
| 3613 extensions_path.AppendASCII("unlimited_quota") | 3616 extensions_path.AppendASCII("unlimited_quota") |
| 3614 .AppendASCII("1.0"); | 3617 .AppendASCII("1.0"); |
| 3615 FilePath unlimited_quota_ext2 = | 3618 FilePath unlimited_quota_ext2 = |
| 3616 extensions_path.AppendASCII("unlimited_quota") | 3619 extensions_path.AppendASCII("unlimited_quota") |
| 3617 .AppendASCII("2.0"); | 3620 .AppendASCII("2.0"); |
| 3618 service_->LoadExtension(limited_quota_ext); | 3621 service_->MakeUnpackedInstaller()->Load(limited_quota_ext); |
| 3619 service_->LoadExtension(unlimited_quota_ext); | 3622 service_->MakeUnpackedInstaller()->Load(unlimited_quota_ext); |
| 3620 service_->LoadExtension(unlimited_quota_ext2); | 3623 service_->MakeUnpackedInstaller()->Load(unlimited_quota_ext2); |
| 3621 loop_.RunAllPending(); | 3624 loop_.RunAllPending(); |
| 3622 | 3625 |
| 3623 ASSERT_EQ(3u, loaded_.size()); | 3626 ASSERT_EQ(3u, loaded_.size()); |
| 3624 EXPECT_TRUE(profile_.get()); | 3627 EXPECT_TRUE(profile_.get()); |
| 3625 EXPECT_FALSE(profile_->IsOffTheRecord()); | 3628 EXPECT_FALSE(profile_->IsOffTheRecord()); |
| 3626 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( | 3629 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( |
| 3627 loaded_[0]->url())); | 3630 loaded_[0]->url())); |
| 3628 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( | 3631 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( |
| 3629 loaded_[1]->url())); | 3632 loaded_[1]->url())); |
| 3630 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( | 3633 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( |
| 3631 loaded_[2]->url())); | 3634 loaded_[2]->url())); |
| 3632 } | 3635 } |
| 3633 | 3636 |
| 3634 // Tests ExtensionService::register_component_extension(). | 3637 // Tests ExtensionService::RegisterComponentExtension(). |
| 3635 TEST_F(ExtensionServiceTest, ComponentExtensions) { | 3638 TEST_F(ExtensionServiceTest, ComponentExtensions) { |
| 3636 InitializeEmptyExtensionService(); | 3639 InitializeEmptyExtensionService(); |
| 3637 | 3640 |
| 3638 // Component extensions should work even when extensions are disabled. | 3641 // Component extensions should work even when extensions are disabled. |
| 3639 set_extensions_enabled(false); | 3642 set_extensions_enabled(false); |
| 3640 | 3643 |
| 3641 FilePath path = data_dir_ | 3644 FilePath path = data_dir_ |
| 3642 .AppendASCII("good") | 3645 .AppendASCII("good") |
| 3643 .AppendASCII("Extensions") | 3646 .AppendASCII("Extensions") |
| 3644 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 3647 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
| 3645 .AppendASCII("1.0.0.0"); | 3648 .AppendASCII("1.0.0.0"); |
| 3646 | 3649 |
| 3647 std::string manifest; | 3650 std::string manifest; |
| 3648 ASSERT_TRUE(file_util::ReadFileToString( | 3651 ASSERT_TRUE(file_util::ReadFileToString( |
| 3649 path.Append(Extension::kManifestFilename), &manifest)); | 3652 path.Append(Extension::kManifestFilename), &manifest)); |
| 3650 | 3653 |
| 3651 service_->register_component_extension( | 3654 service_->component_loader()->RegisterComponentExtension( |
| 3652 ExtensionService::ComponentExtensionInfo(manifest, path)); | 3655 ComponentLoader::ComponentExtensionInfo(manifest, path)); |
| 3653 service_->Init(); | 3656 service_->Init(); |
| 3654 | 3657 |
| 3655 // Note that we do not pump messages -- the extension should be loaded | 3658 // Note that we do not pump messages -- the extension should be loaded |
| 3656 // immediately. | 3659 // immediately. |
| 3657 | 3660 |
| 3658 EXPECT_EQ(0u, GetErrors().size()); | 3661 EXPECT_EQ(0u, GetErrors().size()); |
| 3659 ASSERT_EQ(1u, loaded_.size()); | 3662 ASSERT_EQ(1u, loaded_.size()); |
| 3660 EXPECT_EQ(Extension::COMPONENT, loaded_[0]->location()); | 3663 EXPECT_EQ(Extension::COMPONENT, loaded_[0]->location()); |
| 3661 EXPECT_EQ(1u, service_->extensions()->size()); | 3664 EXPECT_EQ(1u, service_->extensions()->size()); |
| 3662 | 3665 |
| 3663 // Component extensions shouldn't get recourded in the prefs. | 3666 // Component extensions shouldn't get recorded in the prefs. |
| 3664 ValidatePrefKeyCount(0); | 3667 ValidatePrefKeyCount(0); |
| 3665 | 3668 |
| 3666 // Reload all extensions, and make sure it comes back. | 3669 // Reload all extensions, and make sure it comes back. |
| 3667 std::string extension_id = service_->extensions()->at(0)->id(); | 3670 std::string extension_id = service_->extensions()->at(0)->id(); |
| 3668 loaded_.clear(); | 3671 loaded_.clear(); |
| 3669 service_->ReloadExtensions(); | 3672 service_->ReloadExtensions(); |
| 3670 ASSERT_EQ(1u, service_->extensions()->size()); | 3673 ASSERT_EQ(1u, service_->extensions()->size()); |
| 3671 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); | 3674 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); |
| 3672 } | 3675 } |
| 3673 | 3676 |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4234 ASSERT_FALSE(AddPendingSyncInstall()); | 4237 ASSERT_FALSE(AddPendingSyncInstall()); |
| 4235 | 4238 |
| 4236 // Wait for the external source to install. | 4239 // Wait for the external source to install. |
| 4237 WaitForCrxInstall(crx_path_, true); | 4240 WaitForCrxInstall(crx_path_, true); |
| 4238 ASSERT_TRUE(IsCrxInstalled()); | 4241 ASSERT_TRUE(IsCrxInstalled()); |
| 4239 | 4242 |
| 4240 // Now that the extension is installed, sync request should fail | 4243 // Now that the extension is installed, sync request should fail |
| 4241 // because the extension is already installed. | 4244 // because the extension is already installed. |
| 4242 ASSERT_FALSE(AddPendingSyncInstall()); | 4245 ASSERT_FALSE(AddPendingSyncInstall()); |
| 4243 } | 4246 } |
| OLD | NEW |