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

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

Issue 266343002: Unload all apps / extensions when deleting a profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Do not send NULL extension pointer in notifications. Created 6 years, 7 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/extension_service.cc ('k') | chrome/browser/profiles/profile_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_service_unittest.cc
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index a5ed2ba5673364700b8df66e07658ec214909fe8..0fef7adcb47fdec325c3b54f9b9f20c68706c630 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -165,6 +165,7 @@ using extensions::FeatureSwitch;
using extensions::Manifest;
using extensions::PermissionSet;
using extensions::TestExtensionSystem;
+using extensions::UnloadedExtensionInfo;
using extensions::URLPatternSet;
namespace keys = extensions::manifest_keys;
@@ -666,10 +667,12 @@ class ExtensionServiceTest
: public ExtensionServiceTestBase, public content::NotificationObserver {
public:
ExtensionServiceTest()
- : installed_(NULL),
+ : unloaded_reason_(UnloadedExtensionInfo::REASON_UNDEFINED),
+ installed_(NULL),
was_update_(false),
override_external_install_prompt_(
- FeatureSwitch::prompt_for_external_extensions(), false) {
+ FeatureSwitch::prompt_for_external_extensions(),
+ false) {
registrar_.Add(this,
chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
content::NotificationService::AllSources());
@@ -694,10 +697,11 @@ class ExtensionServiceTest
}
case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
- const Extension* e =
- content::Details<extensions::UnloadedExtensionInfo>(
- details)->extension;
+ UnloadedExtensionInfo* unloaded_info =
+ content::Details<UnloadedExtensionInfo>(details).ptr();
+ const Extension* e = unloaded_info->extension;
unloaded_id_ = e->id();
+ unloaded_reason_ = unloaded_info->reason;
extensions::ExtensionList::iterator i =
std::find(loaded_.begin(), loaded_.end(), e);
// TODO(erikkay) fix so this can be an assert. Right now the tests
@@ -1250,6 +1254,7 @@ class ExtensionServiceTest
protected:
extensions::ExtensionList loaded_;
std::string unloaded_id_;
+ UnloadedExtensionInfo::Reason unloaded_reason_;
const Extension* installed_;
bool was_update_;
std::string old_name_;
@@ -4197,6 +4202,7 @@ TEST_F(ExtensionServiceTest, UninstallExtension) {
EXPECT_EQ(1u, registry_->enabled_extensions().size());
UninstallExtension(good_crx, false);
EXPECT_EQ(0u, registry_->enabled_extensions().size());
+ EXPECT_EQ(UnloadedExtensionInfo::REASON_UNINSTALL, unloaded_reason_);
}
TEST_F(ExtensionServiceTest, UninstallTerminatedExtension) {
@@ -4204,6 +4210,7 @@ TEST_F(ExtensionServiceTest, UninstallTerminatedExtension) {
InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
TerminateExtension(good_crx);
UninstallExtension(good_crx, false);
+ EXPECT_EQ(UnloadedExtensionInfo::REASON_TERMINATE, unloaded_reason_);
}
// Tests the uninstaller helper.
@@ -4211,6 +4218,7 @@ TEST_F(ExtensionServiceTest, UninstallExtensionHelper) {
InitializeEmptyExtensionService();
InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
UninstallExtension(good_crx, true);
+ EXPECT_EQ(UnloadedExtensionInfo::REASON_UNINSTALL, unloaded_reason_);
}
TEST_F(ExtensionServiceTest, UninstallExtensionHelperTerminated) {
@@ -4218,6 +4226,7 @@ TEST_F(ExtensionServiceTest, UninstallExtensionHelperTerminated) {
InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
TerminateExtension(good_crx);
UninstallExtension(good_crx, true);
+ EXPECT_EQ(UnloadedExtensionInfo::REASON_TERMINATE, unloaded_reason_);
}
// An extension disabled because of unsupported requirements should re-enabled
@@ -6953,3 +6962,24 @@ TEST_F(ExtensionServiceTest, ReconcileKnownDisabledWithSideEnable) {
EXPECT_EQ(expected_disabled_extensions,
registry_->disabled_extensions().GetIDs());
}
+
+// Tests a profile being destroyed correctly disables extensions.
+TEST_F(ExtensionServiceTest, DestroyingProfileClearsExtensions) {
+ InitializeEmptyExtensionService();
+
+ InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
+ EXPECT_NE(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_);
+ EXPECT_EQ(1u, registry_->enabled_extensions().size());
+ EXPECT_EQ(0u, registry_->disabled_extensions().size());
+ EXPECT_EQ(0u, registry_->terminated_extensions().size());
+ EXPECT_EQ(0u, registry_->blacklisted_extensions().size());
+
+ service_->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
+ content::Source<Profile>(profile_.get()),
+ content::NotificationService::NoDetails());
+ EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_);
+ EXPECT_EQ(0u, registry_->enabled_extensions().size());
+ EXPECT_EQ(0u, registry_->disabled_extensions().size());
+ EXPECT_EQ(0u, registry_->terminated_extensions().size());
+ EXPECT_EQ(0u, registry_->blacklisted_extensions().size());
+}
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/profiles/profile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698