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

Side by Side 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, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <vector> 5 #include <vector>
6 6
7 #include "chrome/browser/apps/ephemeral_app_browsertest.h" 7 #include "chrome/browser/apps/ephemeral_app_browsertest.h"
8 #include "chrome/browser/apps/ephemeral_app_service.h" 8 #include "chrome/browser/apps/ephemeral_app_service.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "content/public/test/test_utils.h" 11 #include "content/public/test/test_utils.h"
12 #include "extensions/browser/extension_prefs.h" 12 #include "extensions/browser/extension_prefs.h"
13 #include "extensions/browser/extension_registry.h"
13 #include "extensions/browser/extension_system.h" 14 #include "extensions/browser/extension_system.h"
14 #include "extensions/common/manifest.h" 15 #include "extensions/common/manifest.h"
15 16
16 using extensions::Extension; 17 using extensions::Extension;
17 using extensions::ExtensionPrefs; 18 using extensions::ExtensionPrefs;
19 using extensions::ExtensionRegistry;
18 using extensions::ExtensionSystem; 20 using extensions::ExtensionSystem;
19 21
20 namespace { 22 namespace {
21 23
22 const int kNumTestApps = 2; 24 const int kNumTestApps = 2;
23 const char* kTestApps[] = { 25 const char* kTestApps[] = {
24 "app_window/generic", 26 "app_window/generic",
25 "minimal" 27 "minimal"
26 }; 28 };
27 29
(...skipping 15 matching lines...) Expand all
43 EphemeralAppService* ephemeral_service = EphemeralAppService::Get( 45 EphemeralAppService* ephemeral_service = EphemeralAppService::Get(
44 browser()->profile()); 46 browser()->profile());
45 ASSERT_TRUE(ephemeral_service); 47 ASSERT_TRUE(ephemeral_service);
46 ephemeral_service->GarbageCollectApps(); 48 ephemeral_service->GarbageCollectApps();
47 } 49 }
48 50
49 void InitEphemeralAppCount(EphemeralAppService* ephemeral_service) { 51 void InitEphemeralAppCount(EphemeralAppService* ephemeral_service) {
50 ephemeral_service->InitEphemeralAppCount(); 52 ephemeral_service->InitEphemeralAppCount();
51 } 53 }
52 54
55 void UnloadEphemeralAppsOnStartup() {
56 EphemeralAppService* ephemeral_service =
57 EphemeralAppService::Get(browser()->profile());
58 ASSERT_TRUE(ephemeral_service);
59 ephemeral_service->UnloadEphemeralAppsOnStartup();
60 }
61
53 std::vector<std::string> app_ids_; 62 std::vector<std::string> app_ids_;
54 }; 63 };
55 64
56 // Verifies that inactive ephemeral apps are uninstalled and active apps are 65 // Verifies that inactive ephemeral apps are uninstalled and active apps are
57 // not removed. Extensive testing of the ephemeral app cache's replacement 66 // not removed. Extensive testing of the ephemeral app cache's replacement
58 // policies is done in the unit tests for EphemeralAppService. This is more 67 // policies is done in the unit tests for EphemeralAppService. This is more
59 // like an integration test. 68 // like an integration test.
60 IN_PROC_BROWSER_TEST_F(EphemeralAppServiceBrowserTest, 69 IN_PROC_BROWSER_TEST_F(EphemeralAppServiceBrowserTest,
61 GarbageCollectInactiveApps) { 70 GarbageCollectInactiveApps) {
62 EphemeralAppService* ephemeral_service = 71 EphemeralAppService* ephemeral_service =
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 GetTestPath(kMessagingReceiverApp).ReplaceExtension( 131 GetTestPath(kMessagingReceiverApp).ReplaceExtension(
123 FILE_PATH_LITERAL(".pem"))); 132 FILE_PATH_LITERAL(".pem")));
124 ASSERT_TRUE(app); 133 ASSERT_TRUE(app);
125 EXPECT_EQ(1, ephemeral_service->ephemeral_app_count()); 134 EXPECT_EQ(1, ephemeral_service->ephemeral_app_count());
126 135
127 // The count should decrease when an ephemeral app is promoted to a regular 136 // The count should decrease when an ephemeral app is promoted to a regular
128 // installed app. 137 // installed app.
129 PromoteEphemeralApp(app); 138 PromoteEphemeralApp(app);
130 EXPECT_EQ(0, ephemeral_service->ephemeral_app_count()); 139 EXPECT_EQ(0, ephemeral_service->ephemeral_app_count());
131 } 140 }
141
142 // Verify that the service will unload and disable ephemeral apps on startup.
143 IN_PROC_BROWSER_TEST_F(EphemeralAppServiceBrowserTest,
144 UnloadEphemeralAppsOnStartup) {
145 const Extension* installed_app = InstallPlatformApp(kNotificationsTestApp);
146 const Extension* running_app =
147 InstallAndLaunchEphemeralApp(kMessagingReceiverApp);
148 const Extension* inactive_app = InstallEphemeralApp(kDispatchEventTestApp);
149 ASSERT_TRUE(installed_app);
150 ASSERT_TRUE(running_app);
151 ASSERT_TRUE(inactive_app);
152
153 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
154 DCHECK(registry);
155 EXPECT_TRUE(registry->enabled_extensions().Contains(installed_app->id()));
156 EXPECT_TRUE(registry->enabled_extensions().Contains(running_app->id()));
157 EXPECT_TRUE(registry->enabled_extensions().Contains(inactive_app->id()));
158
159 UnloadEphemeralAppsOnStartup();
160
161 // Verify that the inactive app is disabled.
162 EXPECT_TRUE(registry->enabled_extensions().Contains(installed_app->id()));
163 EXPECT_TRUE(registry->enabled_extensions().Contains(running_app->id()));
164 EXPECT_TRUE(registry->disabled_extensions().Contains(inactive_app->id()));
165 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698