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 <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 | 576 |
577 // Uninstall is removed from sync and the app is added again. | 577 // Uninstall is removed from sync and the app is added again. |
578 provider()->RemoveUninstalledDriveAppFromSync(kDriveAppId); | 578 provider()->RemoveUninstalledDriveAppFromSync(kDriveAppId); |
579 content::RunAllPendingInMessageLoop(); | 579 content::RunAllPendingInMessageLoop(); |
580 WaitForPendingDriveAppConverters(); | 580 WaitForPendingDriveAppConverters(); |
581 chrome_app_id = mapping()->GetChromeApp(kDriveAppId); | 581 chrome_app_id = mapping()->GetChromeApp(kDriveAppId); |
582 EXPECT_FALSE(chrome_app_id.empty()); | 582 EXPECT_FALSE(chrome_app_id.empty()); |
583 EXPECT_TRUE(ExtensionRegistry::Get(profile())->GetExtensionById( | 583 EXPECT_TRUE(ExtensionRegistry::Get(profile())->GetExtensionById( |
584 chrome_app_id, ExtensionRegistry::EVERYTHING)); | 584 chrome_app_id, ExtensionRegistry::EVERYTHING)); |
585 } | 585 } |
| 586 |
| 587 // Tests that sync changes are processed after DriveAppRegistry is updated. |
| 588 IN_PROC_BROWSER_TEST_F(DriveAppProviderTest, |
| 589 PRE_UpdateAfterDriveAppRegistryUpdate) { |
| 590 // Add a Drive app. |
| 591 fake_drive_service()->AddApp( |
| 592 kDriveAppId, kDriveAppName, kChromeAppId, kLaunchUrl, true); |
| 593 RefreshDriveAppRegistry(); |
| 594 WaitForPendingDriveAppConverters(); |
| 595 |
| 596 // The Drive app is present in the system. |
| 597 std::string chrome_app_id = mapping()->GetChromeApp(kDriveAppId); |
| 598 EXPECT_FALSE(chrome_app_id.empty()); |
| 599 EXPECT_TRUE(ExtensionRegistry::Get(profile())->GetExtensionById( |
| 600 chrome_app_id, ExtensionRegistry::EVERYTHING)); |
| 601 } |
| 602 IN_PROC_BROWSER_TEST_F(DriveAppProviderTest, |
| 603 UpdateAfterDriveAppRegistryUpdate) { |
| 604 // On the next run, uninstall from sync before DriveAppRegistry updates. |
| 605 provider()->AddUninstalledDriveAppFromSync(kDriveAppId); |
| 606 content::RunAllPendingInMessageLoop(); |
| 607 WaitForPendingDriveAppConverters(); |
| 608 |
| 609 // The app should still be there. |
| 610 std::string chrome_app_id = mapping()->GetChromeApp(kDriveAppId); |
| 611 EXPECT_FALSE(chrome_app_id.empty()); |
| 612 EXPECT_TRUE(ExtensionRegistry::Get(profile())->GetExtensionById( |
| 613 chrome_app_id, ExtensionRegistry::EVERYTHING)); |
| 614 |
| 615 // Now update DriveAppRegistry. |
| 616 fake_drive_service()->AddApp( |
| 617 kDriveAppId, kDriveAppName, kChromeAppId, kLaunchUrl, true); |
| 618 RefreshDriveAppRegistry(); |
| 619 WaitForPendingDriveAppConverters(); |
| 620 |
| 621 // The app should be gone. |
| 622 chrome_app_id = mapping()->GetChromeApp(kDriveAppId); |
| 623 EXPECT_TRUE(chrome_app_id.empty()); |
| 624 EXPECT_FALSE(ExtensionRegistry::Get(profile())->GetExtensionById( |
| 625 chrome_app_id, ExtensionRegistry::EVERYTHING)); |
| 626 } |
OLD | NEW |