Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5254)

Unified Diff: chrome/browser/extensions/extensions_service_unittest.cc

Issue 2845025: Fixed memory leak in ExtensionsService. (Closed)
Patch Set: Addressed asargent's comments, added tests Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extensions_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extensions_service_unittest.cc
diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc
index cc50bab40f95fc84563aadaf291de8e68e379dd8..58255da117a90beee8b7988545257d2dd4dc0831 100644
--- a/chrome/browser/extensions/extensions_service_unittest.cc
+++ b/chrome/browser/extensions/extensions_service_unittest.cc
@@ -1437,6 +1437,66 @@ TEST_F(ExtensionsServiceTest, WillNotLoadBlacklistedExtensionsFromDirectory) {
EXPECT_NE(std::string(good0), loaded_[1]->id());
}
+// Tests disabling extensions
+TEST_F(ExtensionsServiceTest, DisableExtension) {
+ InitializeEmptyExtensionsService();
+ FilePath extensions_path;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
+ extensions_path = extensions_path.AppendASCII("extensions");
+
+ // A simple extension that should install without error.
+ FilePath path = extensions_path.AppendASCII("good.crx");
+ InstallExtension(path, true);
+
+ const char* extension_id = good_crx;
+ EXPECT_FALSE(service_->extensions()->empty());
+ EXPECT_TRUE(service_->GetExtensionById(extension_id, true) != NULL);
+ EXPECT_TRUE(service_->GetExtensionById(extension_id, false) != NULL);
+ EXPECT_TRUE(service_->disabled_extensions()->empty());
+
+ // Disable it.
+ service_->DisableExtension(extension_id);
+
+ EXPECT_TRUE(service_->extensions()->empty());
+ EXPECT_TRUE(service_->GetExtensionById(extension_id, true) != NULL);
+ EXPECT_FALSE(service_->GetExtensionById(extension_id, false) != NULL);
+ EXPECT_FALSE(service_->disabled_extensions()->empty());
+}
+
+// Tests reloading extensions
+TEST_F(ExtensionsServiceTest, ReloadExtensions) {
+ InitializeEmptyExtensionsService();
+ FilePath extensions_path;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
+ extensions_path = extensions_path.AppendASCII("extensions");
+
+ // Simple extension that should install without error.
+ FilePath path = extensions_path.AppendASCII("good.crx");
+ InstallExtension(path, true);
+ const char* extension_id = good_crx;
+ service_->DisableExtension(extension_id);
+
+ EXPECT_EQ(0u, service_->extensions()->size());
+ EXPECT_EQ(1u, service_->disabled_extensions()->size());
+
+ service_->ReloadExtensions();
+
+ // Extension counts shouldn't change.
+ EXPECT_EQ(0u, service_->extensions()->size());
+ EXPECT_EQ(1u, service_->disabled_extensions()->size());
+
+ service_->EnableExtension(extension_id);
+
+ EXPECT_EQ(1u, service_->extensions()->size());
+ EXPECT_EQ(0u, service_->disabled_extensions()->size());
+
+ service_->ReloadExtensions();
+
+ // Extension counts shouldn't change.
+ EXPECT_EQ(1u, service_->extensions()->size());
+ EXPECT_EQ(0u, service_->disabled_extensions()->size());
+}
+
// Tests uninstalling normal extensions
TEST_F(ExtensionsServiceTest, UninstallExtension) {
InitializeEmptyExtensionsService();
« no previous file with comments | « chrome/browser/extensions/extensions_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698