OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/apps/drive/drive_app_provider.h" | 5 #include "chrome/browser/apps/drive/drive_app_provider.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 EXPECT_FALSE(fake_drive_service()->HasApp(kDriveAppId)); | 270 EXPECT_FALSE(fake_drive_service()->HasApp(kDriveAppId)); |
271 } | 271 } |
272 | 272 |
273 // A matching Chrome app replaces the created URL app. | 273 // A matching Chrome app replaces the created URL app. |
274 IN_PROC_BROWSER_TEST_F(DriveAppProviderTest, MatchingChromeAppInstalled) { | 274 IN_PROC_BROWSER_TEST_F(DriveAppProviderTest, MatchingChromeAppInstalled) { |
275 // Prepare a Drive app that matches the not-yet-installed kChromeAppId. | 275 // Prepare a Drive app that matches the not-yet-installed kChromeAppId. |
276 fake_drive_service()->AddApp( | 276 fake_drive_service()->AddApp( |
277 kDriveAppId, kDriveAppName, kChromeAppId, kLaunchUrl, true); | 277 kDriveAppId, kDriveAppName, kChromeAppId, kLaunchUrl, true); |
278 RefreshDriveAppRegistry(); | 278 RefreshDriveAppRegistry(); |
279 WaitForPendingDriveAppConverters(); | 279 WaitForPendingDriveAppConverters(); |
280 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | |
281 | 280 |
282 // An Url app should be created. | 281 // An Url app should be created. |
283 const Extension* url_app = registry->GetExtensionById( | 282 const Extension* url_app = |
284 mapping()->GetChromeApp(kDriveAppId), ExtensionRegistry::EVERYTHING); | 283 ExtensionRegistry::Get(profile())->GetExtensionById( |
| 284 mapping()->GetChromeApp(kDriveAppId), ExtensionRegistry::EVERYTHING); |
285 EXPECT_TRUE(url_app->is_hosted_app()); | 285 EXPECT_TRUE(url_app->is_hosted_app()); |
286 EXPECT_TRUE(url_app->from_bookmark()); | 286 EXPECT_TRUE(url_app->from_bookmark()); |
287 | 287 |
288 const std::string url_app_id = url_app->id(); | 288 const std::string url_app_id = url_app->id(); |
289 EXPECT_NE(kChromeAppId, url_app_id); | 289 EXPECT_NE(kChromeAppId, url_app_id); |
290 EXPECT_EQ(url_app_id, mapping()->GetChromeApp(kDriveAppId)); | 290 EXPECT_EQ(url_app_id, mapping()->GetChromeApp(kDriveAppId)); |
291 EXPECT_TRUE(mapping()->IsChromeAppGenerated(url_app_id)); | 291 EXPECT_TRUE(mapping()->IsChromeAppGenerated(url_app_id)); |
292 | 292 |
293 // Install a chrome app with matching id. | 293 // Installs a chrome app with matching id. |
294 size_t num_before = registry->enabled_extensions().size(); | 294 InstallChromeApp(0); |
295 InstallChromeApp(1); | |
296 // Url app should be auto uninstalled. This happens asynchronously after the | |
297 // installation of the app that replaces it, so the task might still be | |
298 // pending. | |
299 content::RunAllPendingInMessageLoop(); | |
300 EXPECT_FALSE( | |
301 registry->GetExtensionById(url_app_id, ExtensionRegistry::EVERYTHING)); | |
302 EXPECT_EQ(num_before, registry->enabled_extensions().size()); | |
303 | 295 |
304 // The Drive app should be mapped to chrome app. | 296 // The Drive app should be mapped to chrome app. |
305 EXPECT_EQ(kChromeAppId, mapping()->GetChromeApp(kDriveAppId)); | 297 EXPECT_EQ(kChromeAppId, mapping()->GetChromeApp(kDriveAppId)); |
306 EXPECT_FALSE(mapping()->IsChromeAppGenerated(kChromeAppId)); | 298 EXPECT_FALSE(mapping()->IsChromeAppGenerated(kChromeAppId)); |
| 299 |
| 300 // Url app should be auto uninstalled. |
| 301 EXPECT_FALSE(ExtensionRegistry::Get(profile())->GetExtensionById( |
| 302 url_app_id, ExtensionRegistry::EVERYTHING)); |
307 } | 303 } |
308 | 304 |
309 // Tests that the corresponding URL app is uninstalled when a Drive app is | 305 // Tests that the corresponding URL app is uninstalled when a Drive app is |
310 // disconnected. | 306 // disconnected. |
311 IN_PROC_BROWSER_TEST_F(DriveAppProviderTest, | 307 IN_PROC_BROWSER_TEST_F(DriveAppProviderTest, |
312 DisconnectDriveAppUninstallUrlApp) { | 308 DisconnectDriveAppUninstallUrlApp) { |
313 // Prepare a Drive app that matches the not-yet-installed kChromeAppId. | 309 // Prepare a Drive app that matches the not-yet-installed kChromeAppId. |
314 fake_drive_service()->AddApp( | 310 fake_drive_service()->AddApp( |
315 kDriveAppId, kDriveAppName, kChromeAppId, kLaunchUrl, true); | 311 kDriveAppId, kDriveAppName, kChromeAppId, kLaunchUrl, true); |
316 RefreshDriveAppRegistry(); | 312 RefreshDriveAppRegistry(); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 kDriveAppId, kDriveAppName, kChromeAppId, kLaunchUrl, true); | 617 kDriveAppId, kDriveAppName, kChromeAppId, kLaunchUrl, true); |
622 RefreshDriveAppRegistry(); | 618 RefreshDriveAppRegistry(); |
623 WaitForPendingDriveAppConverters(); | 619 WaitForPendingDriveAppConverters(); |
624 | 620 |
625 // The app should be gone. | 621 // The app should be gone. |
626 chrome_app_id = mapping()->GetChromeApp(kDriveAppId); | 622 chrome_app_id = mapping()->GetChromeApp(kDriveAppId); |
627 EXPECT_TRUE(chrome_app_id.empty()); | 623 EXPECT_TRUE(chrome_app_id.empty()); |
628 EXPECT_FALSE(ExtensionRegistry::Get(profile())->GetExtensionById( | 624 EXPECT_FALSE(ExtensionRegistry::Get(profile())->GetExtensionById( |
629 chrome_app_id, ExtensionRegistry::EVERYTHING)); | 625 chrome_app_id, ExtensionRegistry::EVERYTHING)); |
630 } | 626 } |
OLD | NEW |