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

Unified Diff: chrome/browser/apps/ephemeral_app_service_browsertest.cc

Issue 344543006: Disable ephemeral apps after they stop running (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Prevent demotion of installed app due to race condition Created 6 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
Index: chrome/browser/apps/ephemeral_app_service_browsertest.cc
diff --git a/chrome/browser/apps/ephemeral_app_service_browsertest.cc b/chrome/browser/apps/ephemeral_app_service_browsertest.cc
index 9ecf7a8ad18c4aa5be0251e0854a97b1a28df3ba..9165c030ee7e11d6f41b1c79a60941835e6bf36d 100644
--- a/chrome/browser/apps/ephemeral_app_service_browsertest.cc
+++ b/chrome/browser/apps/ephemeral_app_service_browsertest.cc
@@ -10,11 +10,13 @@
#include "chrome/browser/profiles/profile.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/extension_prefs.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/manifest.h"
using extensions::Extension;
using extensions::ExtensionPrefs;
+using extensions::ExtensionRegistry;
using extensions::ExtensionSystem;
namespace {
@@ -50,6 +52,13 @@ class EphemeralAppServiceBrowserTest : public EphemeralAppTestBase {
ephemeral_service->InitEphemeralAppCount();
}
+ void UnloadEphemeralAppsOnStartup() {
+ EphemeralAppService* ephemeral_service =
+ EphemeralAppService::Get(browser()->profile());
+ ASSERT_TRUE(ephemeral_service);
+ ephemeral_service->UnloadEphemeralAppsOnStartup();
+ }
+
std::vector<std::string> app_ids_;
};
@@ -129,3 +138,28 @@ IN_PROC_BROWSER_TEST_F(EphemeralAppServiceBrowserTest,
PromoteEphemeralApp(app);
EXPECT_EQ(0, ephemeral_service->ephemeral_app_count());
}
+
+// Verify that the service will unload and disable ephemeral apps on startup.
+IN_PROC_BROWSER_TEST_F(EphemeralAppServiceBrowserTest,
+ UnloadEphemeralAppsOnStartup) {
+ const Extension* installed_app = InstallPlatformApp(kNotificationsTestApp);
+ const Extension* running_app =
+ InstallAndLaunchEphemeralApp(kMessagingReceiverApp);
+ const Extension* inactive_app = InstallEphemeralApp(kDispatchEventTestApp);
+ ASSERT_TRUE(installed_app);
+ ASSERT_TRUE(running_app);
+ ASSERT_TRUE(inactive_app);
+
+ ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
+ DCHECK(registry);
+ EXPECT_TRUE(registry->enabled_extensions().Contains(installed_app->id()));
+ EXPECT_TRUE(registry->enabled_extensions().Contains(running_app->id()));
+ EXPECT_TRUE(registry->enabled_extensions().Contains(inactive_app->id()));
+
+ UnloadEphemeralAppsOnStartup();
+
+ // Verify that the inactive app is disabled.
+ EXPECT_TRUE(registry->enabled_extensions().Contains(installed_app->id()));
+ EXPECT_TRUE(registry->enabled_extensions().Contains(running_app->id()));
+ EXPECT_TRUE(registry->disabled_extensions().Contains(inactive_app->id()));
+}

Powered by Google App Engine
This is Rietveld 408576698