OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extensions_service_unittest.h" | 5 #include "chrome/browser/extensions/extensions_service_unittest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 ASSERT_EQ(1u, loaded_.size()); | 962 ASSERT_EQ(1u, loaded_.size()); |
963 ASSERT_EQ(0u, GetErrors().size()); | 963 ASSERT_EQ(0u, GetErrors().size()); |
964 ValidatePrefKeyCount(1); | 964 ValidatePrefKeyCount(1); |
965 ValidateIntegerPref(good_crx, L"state", Extension::ENABLED); | 965 ValidateIntegerPref(good_crx, L"state", Extension::ENABLED); |
966 ValidateIntegerPref(good_crx, L"location", Extension::INTERNAL); | 966 ValidateIntegerPref(good_crx, L"location", Extension::INTERNAL); |
967 | 967 |
968 installed_ = NULL; | 968 installed_ = NULL; |
969 loaded_.clear(); | 969 loaded_.clear(); |
970 ExtensionErrorReporter::GetInstance()->ClearErrors(); | 970 ExtensionErrorReporter::GetInstance()->ClearErrors(); |
971 | 971 |
972 // Reinstall the same version, nothing should happen. | 972 // Reinstall the same version, it should overwrite the previous one. |
973 service_->InstallExtension(path); | 973 service_->InstallExtension(path); |
974 loop_.RunAllPending(); | 974 loop_.RunAllPending(); |
975 | 975 |
976 ASSERT_FALSE(installed_); | 976 ASSERT_TRUE(installed_); |
977 ASSERT_EQ(0u, loaded_.size()); | 977 ASSERT_EQ(1u, loaded_.size()); |
978 ASSERT_EQ(0u, GetErrors().size()); | 978 ASSERT_EQ(0u, GetErrors().size()); |
979 ValidatePrefKeyCount(1); | 979 ValidatePrefKeyCount(1); |
980 ValidateIntegerPref(good_crx, L"state", Extension::ENABLED); | 980 ValidateIntegerPref(good_crx, L"state", Extension::ENABLED); |
981 ValidateIntegerPref(good_crx, L"location", Extension::INTERNAL); | 981 ValidateIntegerPref(good_crx, L"location", Extension::INTERNAL); |
982 } | 982 } |
983 | 983 |
984 // Test upgrading a signed extension. | 984 // Test upgrading a signed extension. |
985 TEST_F(ExtensionsServiceTest, UpgradeSignedGood) { | 985 TEST_F(ExtensionsServiceTest, UpgradeSignedGood) { |
986 InitializeEmptyExtensionsService(); | 986 InitializeEmptyExtensionsService(); |
987 FilePath extensions_path; | 987 FilePath extensions_path; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 Extension* good = service_->extensions()->at(0); | 1211 Extension* good = service_->extensions()->at(0); |
1212 | 1212 |
1213 // Use AddPendingExtensionInternal() as AddPendingExtension() would | 1213 // Use AddPendingExtensionInternal() as AddPendingExtension() would |
1214 // balk. | 1214 // balk. |
1215 service_->AddPendingExtensionInternal( | 1215 service_->AddPendingExtensionInternal( |
1216 good->id(), good->update_url(), *good->version(), | 1216 good->id(), good->update_url(), *good->version(), |
1217 good->IsTheme(), kGoodInstallSilently); | 1217 good->IsTheme(), kGoodInstallSilently); |
1218 | 1218 |
1219 UpdateExtension(good->id(), path, true, true, false); | 1219 UpdateExtension(good->id(), path, true, true, false); |
1220 | 1220 |
1221 EXPECT_TRUE(ContainsKey(service_->pending_extensions(), kGoodId)); | 1221 EXPECT_FALSE(ContainsKey(service_->pending_extensions(), kGoodId)); |
1222 } | 1222 } |
1223 | 1223 |
1224 // Test pref settings for blacklist and unblacklist extensions. | 1224 // Test pref settings for blacklist and unblacklist extensions. |
1225 TEST_F(ExtensionsServiceTest, SetUnsetBlacklistInPrefs) { | 1225 TEST_F(ExtensionsServiceTest, SetUnsetBlacklistInPrefs) { |
1226 InitializeEmptyExtensionsService(); | 1226 InitializeEmptyExtensionsService(); |
1227 std::vector<std::string> blacklist; | 1227 std::vector<std::string> blacklist; |
1228 blacklist.push_back(good0); | 1228 blacklist.push_back(good0); |
1229 blacklist.push_back("invalid_id"); // an invalid id | 1229 blacklist.push_back("invalid_id"); // an invalid id |
1230 blacklist.push_back(good1); | 1230 blacklist.push_back(good1); |
1231 service_->UpdateExtensionBlacklist(blacklist); | 1231 service_->UpdateExtensionBlacklist(blacklist); |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 // Component extensions shouldn't get recourded in the prefs. | 1906 // Component extensions shouldn't get recourded in the prefs. |
1907 ValidatePrefKeyCount(0); | 1907 ValidatePrefKeyCount(0); |
1908 | 1908 |
1909 // Reload all extensions, and make sure it comes back. | 1909 // Reload all extensions, and make sure it comes back. |
1910 std::string extension_id = service_->extensions()->at(0)->id(); | 1910 std::string extension_id = service_->extensions()->at(0)->id(); |
1911 loaded_.clear(); | 1911 loaded_.clear(); |
1912 service_->ReloadExtensions(); | 1912 service_->ReloadExtensions(); |
1913 ASSERT_EQ(1u, service_->extensions()->size()); | 1913 ASSERT_EQ(1u, service_->extensions()->size()); |
1914 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); | 1914 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); |
1915 } | 1915 } |
OLD | NEW |