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

Side by Side Diff: chrome/browser/apps/ephemeral_app_service_browsertest.cc

Issue 383703002: Clear the ephemeral app cache from Clear Browsing Data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 ExtensionService* service = ExtensionSystem::Get(browser()->profile()) 92 ExtensionService* service = ExtensionSystem::Get(browser()->profile())
93 ->extension_service(); 93 ->extension_service();
94 ASSERT_TRUE(service); 94 ASSERT_TRUE(service);
95 EXPECT_FALSE(service->GetInstalledExtension(inactive_app_id)); 95 EXPECT_FALSE(service->GetInstalledExtension(inactive_app_id));
96 EXPECT_TRUE(service->GetInstalledExtension(active_app_id)); 96 EXPECT_TRUE(service->GetInstalledExtension(active_app_id));
97 97
98 EXPECT_EQ(1, ephemeral_service->ephemeral_app_count()); 98 EXPECT_EQ(1, ephemeral_service->ephemeral_app_count());
99 } 99 }
100 100
101 // Verify that the count of ephemeral apps is maintained correctly. 101 // Verify that the count of ephemeral apps is maintained correctly.
102 IN_PROC_BROWSER_TEST_F(EphemeralAppServiceBrowserTest, 102 IN_PROC_BROWSER_TEST_F(EphemeralAppServiceBrowserTest, EphemeralAppCount) {
103 EphemeralAppCount) {
104 EphemeralAppService* ephemeral_service = 103 EphemeralAppService* ephemeral_service =
105 EphemeralAppService::Get(browser()->profile()); 104 EphemeralAppService::Get(browser()->profile());
106 ASSERT_TRUE(ephemeral_service); 105 ASSERT_TRUE(ephemeral_service);
107 InitEphemeralAppCount(ephemeral_service); 106 InitEphemeralAppCount(ephemeral_service);
108 107
109 // The count should not increase for regular installed apps. 108 // The count should not increase for regular installed apps.
110 EXPECT_TRUE(InstallPlatformApp("minimal")); 109 EXPECT_TRUE(InstallPlatformApp("minimal"));
111 EXPECT_EQ(0, ephemeral_service->ephemeral_app_count()); 110 EXPECT_EQ(0, ephemeral_service->ephemeral_app_count());
112 111
113 // The count should increase when an ephemeral app is added. 112 // The count should increase when an ephemeral app is added.
114 const Extension* app = InstallEphemeralApp(kMessagingReceiverApp); 113 const Extension* app = InstallEphemeralApp(kMessagingReceiverApp);
115 ASSERT_TRUE(app); 114 ASSERT_TRUE(app);
116 EXPECT_EQ(1, ephemeral_service->ephemeral_app_count()); 115 EXPECT_EQ(1, ephemeral_service->ephemeral_app_count());
117 116
118 // The count should remain constant if the ephemeral app is updated. 117 // The count should remain constant if the ephemeral app is updated.
119 const std::string app_id = app->id(); 118 const std::string app_id = app->id();
120 app = UpdateEphemeralApp( 119 app = UpdateEphemeralApp(
121 app_id, GetTestPath(kMessagingReceiverAppV2), 120 app_id, GetTestPath(kMessagingReceiverAppV2),
122 GetTestPath(kMessagingReceiverApp).ReplaceExtension( 121 GetTestPath(kMessagingReceiverApp).ReplaceExtension(
123 FILE_PATH_LITERAL(".pem"))); 122 FILE_PATH_LITERAL(".pem")));
124 ASSERT_TRUE(app); 123 ASSERT_TRUE(app);
125 EXPECT_EQ(1, ephemeral_service->ephemeral_app_count()); 124 EXPECT_EQ(1, ephemeral_service->ephemeral_app_count());
126 125
127 // The count should decrease when an ephemeral app is promoted to a regular 126 // The count should decrease when an ephemeral app is promoted to a regular
128 // installed app. 127 // installed app.
129 PromoteEphemeralApp(app); 128 PromoteEphemeralApp(app);
130 EXPECT_EQ(0, ephemeral_service->ephemeral_app_count()); 129 EXPECT_EQ(0, ephemeral_service->ephemeral_app_count());
131 } 130 }
131
132 // Verify that the cache of ephemeral apps is correctly cleared. Running apps
133 // should not be removed.
134 IN_PROC_BROWSER_TEST_F(EphemeralAppServiceBrowserTest, ClearCachedApps) {
135 const Extension* running_app =
136 InstallAndLaunchEphemeralApp(kMessagingReceiverApp);
137 const Extension* inactive_app =
138 InstallAndLaunchEphemeralApp(kDispatchEventTestApp);
139 std::string inactive_app_id = inactive_app->id();
140 std::string running_app_id = running_app->id();
141 CloseApp(inactive_app_id);
142
143 EphemeralAppService* ephemeral_service =
144 EphemeralAppService::Get(browser()->profile());
145 ASSERT_TRUE(ephemeral_service);
146 ephemeral_service->ClearCachedApps();
tapted 2014/07/11 01:16:36 before this, perhaps EXPECT_EQ(2, ephemeral_servic
tmdiep 2014/07/11 03:11:43 Done.
147
148 ExtensionService* service =
149 ExtensionSystem::Get(browser()->profile())->extension_service();
tapted 2014/07/11 01:16:36 nit: I think you're inheriting an `extension_servi
tmdiep 2014/07/11 03:11:43 Updated to use ExtensionRegistry since the functio
150 ASSERT_TRUE(service);
151 EXPECT_FALSE(service->GetInstalledExtension(inactive_app_id));
152 EXPECT_TRUE(service->GetInstalledExtension(running_app_id));
153
154 EXPECT_EQ(1, ephemeral_service->ephemeral_app_count());
155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698