Chromium Code Reviews| Index: chrome/browser/extensions/extension_service_unittest.cc |
| diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc |
| index c07d02597a8357de255f6f1119823ae741ab0848..a793868cfcf1639c921ebf5dfae9a3b577c31d08 100644 |
| --- a/chrome/browser/extensions/extension_service_unittest.cc |
| +++ b/chrome/browser/extensions/extension_service_unittest.cc |
| @@ -30,6 +30,7 @@ |
| #include "chrome/browser/extensions/app_sync_data.h" |
| #include "chrome/browser/extensions/component_loader.h" |
| #include "chrome/browser/extensions/crx_installer.h" |
| +#include "chrome/browser/extensions/default_apps.h" |
| #include "chrome/browser/extensions/extension_creator.h" |
| #include "chrome/browser/extensions/extension_error_reporter.h" |
| #include "chrome/browser/extensions/extension_error_ui.h" |
| @@ -3721,6 +3722,50 @@ TEST_F(ExtensionServiceTest, ExternalInstallPref) { |
| TestExternalProvider(pref_provider, Extension::EXTERNAL_PREF); |
| } |
| +TEST_F(ExtensionServiceTest, DefaultAppsInstall) { |
| + scoped_ptr<TestingProfile> profile(new TestingProfile()); |
| + |
| + // The default apps should be installed if kDefaultAppsInstallState |
| + // is unknown. |
| + EXPECT_TRUE(default_apps::ShouldInstallInProfile(profile.get())); |
| + int state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); |
| + EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps); |
| + |
| + // The default apps should only be installed once. |
| + EXPECT_FALSE(default_apps::ShouldInstallInProfile(profile.get())); |
| + state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); |
| + EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps); |
| + |
| + // The default apps should not be installed if the state is |
| + // kNeverProvideDefaultApps |
| + profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState, |
| + default_apps::kNeverInstallDefaultApps); |
| + EXPECT_FALSE(default_apps::ShouldInstallInProfile(profile.get())); |
| + state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); |
| + EXPECT_TRUE(state == default_apps::kNeverInstallDefaultApps); |
| + |
| + // The old default apps with kAlwaysInstallDefaultAppss should be migrated. |
| + profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState, |
| + default_apps::kProvideLegacyDefaultApps); |
| + EXPECT_TRUE(default_apps::ShouldInstallInProfile(profile.get())); |
| + state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); |
| + EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps); |
| + |
| + class DefaultTestingProfile : public TestingProfile { |
| + bool WasCreatedByVersionOrLater(const std::string& version) { |
|
Mihai Parparita -not on Chrome
2012/08/21 22:03:56
Seems like this needs virtual and OVERRIDE annotat
|
| + return false; |
| + } |
| + }; |
| + profile.reset(new DefaultTestingProfile); |
| + // The old default apps with kProvideLegacyDefaultApps should be migrated |
| + // even if the profile version is older than Chrome version. |
| + profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState, |
| + default_apps::kProvideLegacyDefaultApps); |
| + EXPECT_TRUE(default_apps::ShouldInstallInProfile(profile.get())); |
| + state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); |
| + EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps); |
| +} |
| + |
| TEST_F(ExtensionServiceTest, ExternalInstallPrefUpdateUrl) { |
| // This should all work, even when normal extension installation is disabled. |
| InitializeEmptyExtensionService(); |