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

Side by Side Diff: chrome/browser/extensions/default_apps_unittest.cc

Issue 10875065: Disable install of new default_apps for existing users (Closed) Base URL: http://git.chromium.org/git/chromium.git@disable_sync_behav
Patch Set: made destructor private Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/external_pref_loader.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/extensions/default_apps.h"
9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/common/chrome_paths.h"
11 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/pref_names.h"
13 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/test/test_browser_thread.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 using default_apps::Provider;
18 using namespace extensions;
19
20 class MockExternalLoader : public ExternalLoader {
21 public:
22 MockExternalLoader() {}
23
24 void StartLoading() {return;}
Mihai Parparita -not on Chrome 2012/08/30 00:31:24 Nit: unnecessary return statement. (can be fixed
25 private:
26 virtual ~MockExternalLoader() {}
27 };
28
29 class DefaultAppsTest : public testing::Test {
30 public:
31 DefaultAppsTest() : loop_(MessageLoop::TYPE_IO),
32 ui_thread_(content::BrowserThread::UI, &loop_) {}
33 virtual ~DefaultAppsTest() {}
34 private:
35 MessageLoop loop_;
36 content::TestBrowserThread ui_thread_;
37 };
38
39 #if !defined(OS_CHROMEOS)
40 // Chrome OS has different way of installing default apps.
41 TEST_F(DefaultAppsTest, Install) {
42 scoped_ptr<TestingProfile> profile(new TestingProfile());
43 extensions::ExternalLoader* loader = new MockExternalLoader();
44
45
46 Provider provider(profile.get(), NULL, loader, Extension::INTERNAL,
47 Extension::INTERNAL, Extension::NO_FLAGS);
48
49 // The default apps should be installed if kDefaultAppsInstallState
50 // is unknown.
51 EXPECT_TRUE(provider.ShouldInstallInProfile());
52 int state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState);
53 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps);
54
55 // The default apps should only be installed once.
56 EXPECT_FALSE(provider.ShouldInstallInProfile());
57 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState);
58 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps);
59
60 // The default apps should not be installed if the state is
61 // kNeverProvideDefaultApps
62 profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState,
63 default_apps::kNeverInstallDefaultApps);
64 EXPECT_FALSE(provider.ShouldInstallInProfile());
65 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState);
66 EXPECT_TRUE(state == default_apps::kNeverInstallDefaultApps);
67
68 // The old default apps with kAlwaysInstallDefaultAppss should be migrated.
69 profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState,
70 default_apps::kProvideLegacyDefaultApps);
71 EXPECT_TRUE(provider.ShouldInstallInProfile());
72 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState);
73 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps);
74
75 class DefaultTestingProfile : public TestingProfile {
76 virtual bool WasCreatedByVersionOrLater(
77 const std::string& version) OVERRIDE {
78 return false;
79 }
80 };
81 profile.reset(new DefaultTestingProfile);
82 Provider provider2(profile.get(), NULL, loader, Extension::INTERNAL,
83 Extension::INTERNAL, Extension::NO_FLAGS);
84 // The old default apps with kProvideLegacyDefaultApps should be migrated
85 // even if the profile version is older than Chrome version.
86 profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState,
87 default_apps::kProvideLegacyDefaultApps);
88 EXPECT_TRUE(provider2.ShouldInstallInProfile());
89 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState);
90 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps);
91 }
92 #endif
OLDNEW
« no previous file with comments | « chrome/browser/extensions/default_apps.cc ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698