OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/external_pref_loader.h" | 5 #include "chrome/browser/extensions/external_pref_loader.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/extensions/default_apps.h" | 8 #include "chrome/browser/extensions/default_apps.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 }; | 37 }; |
38 | 38 |
39 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 39 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
40 // Chrome OS has different way of installing default apps. | 40 // Chrome OS has different way of installing default apps. |
41 // Android does not currently support installing apps via Chrome. | 41 // Android does not currently support installing apps via Chrome. |
42 TEST_F(DefaultAppsTest, Install) { | 42 TEST_F(DefaultAppsTest, Install) { |
43 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 43 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
44 extensions::ExternalLoader* loader = new MockExternalLoader(); | 44 extensions::ExternalLoader* loader = new MockExternalLoader(); |
45 | 45 |
46 | 46 |
47 Provider provider(profile.get(), NULL, loader, Extension::INTERNAL, | 47 Provider provider(profile.get(), NULL, loader, Manifest::INTERNAL, |
48 Extension::INTERNAL, Extension::NO_FLAGS); | 48 Manifest::INTERNAL, Extension::NO_FLAGS); |
49 | 49 |
50 // The default apps should be installed if kDefaultAppsInstallState | 50 // The default apps should be installed if kDefaultAppsInstallState |
51 // is unknown. | 51 // is unknown. |
52 EXPECT_TRUE(provider.ShouldInstallInProfile()); | 52 EXPECT_TRUE(provider.ShouldInstallInProfile()); |
53 int state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); | 53 int state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); |
54 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps); | 54 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps); |
55 | 55 |
56 // The default apps should only be installed once. | 56 // The default apps should only be installed once. |
57 EXPECT_FALSE(provider.ShouldInstallInProfile()); | 57 EXPECT_FALSE(provider.ShouldInstallInProfile()); |
58 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); | 58 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); |
(...skipping 14 matching lines...) Expand all Loading... |
73 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); | 73 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); |
74 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps); | 74 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps); |
75 | 75 |
76 class DefaultTestingProfile : public TestingProfile { | 76 class DefaultTestingProfile : public TestingProfile { |
77 virtual bool WasCreatedByVersionOrLater( | 77 virtual bool WasCreatedByVersionOrLater( |
78 const std::string& version) OVERRIDE { | 78 const std::string& version) OVERRIDE { |
79 return false; | 79 return false; |
80 } | 80 } |
81 }; | 81 }; |
82 profile.reset(new DefaultTestingProfile); | 82 profile.reset(new DefaultTestingProfile); |
83 Provider provider2(profile.get(), NULL, loader, Extension::INTERNAL, | 83 Provider provider2(profile.get(), NULL, loader, Manifest::INTERNAL, |
84 Extension::INTERNAL, Extension::NO_FLAGS); | 84 Manifest::INTERNAL, Extension::NO_FLAGS); |
85 // The old default apps with kProvideLegacyDefaultApps should be migrated | 85 // The old default apps with kProvideLegacyDefaultApps should be migrated |
86 // even if the profile version is older than Chrome version. | 86 // even if the profile version is older than Chrome version. |
87 profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState, | 87 profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState, |
88 default_apps::kProvideLegacyDefaultApps); | 88 default_apps::kProvideLegacyDefaultApps); |
89 EXPECT_TRUE(provider2.ShouldInstallInProfile()); | 89 EXPECT_TRUE(provider2.ShouldInstallInProfile()); |
90 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); | 90 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState); |
91 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps); | 91 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps); |
92 } | 92 } |
93 #endif | 93 #endif |
OLD | NEW |