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

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: . 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 "base/memory/scoped_ptr.h"
6 #include "chrome/browser/extensions/default_apps.h"
7 #include "chrome/browser/prefs/pref_service.h"
8 #include "chrome/common/extensions/extension.h"
9 #include "chrome/common/pref_names.h"
10 #include "chrome/test/base/testing_profile.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 using default_apps::Provider;
14
15 class DefaultAppsTest : public testing::Test {
16 public:
17 DefaultAppsTest() {}
18 virtual ~DefaultAppsTest() {}
19 };
20
21 #if !defined(OS_CHROMEOS)
22 // Chrome OS has different way of installing default apps.
23 TEST_F(DefaultAppsTest, Install) {
24 scoped_ptr<TestingProfile> profile(new TestingProfile());
25
26 // The default apps should be installed if kDefaultAppsInstallState
27 // is unknown.
28 EXPECT_TRUE(Provider::ShouldInstallInProfile(profile.get()));
29 int state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState);
30 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps);
31
32 // The default apps should only be installed once.
33 EXPECT_FALSE(Provider::ShouldInstallInProfile(profile.get()));
34 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState);
35 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps);
36
37 // The default apps should not be installed if the state is
38 // kNeverProvideDefaultApps
39 profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState,
40 default_apps::kNeverInstallDefaultApps);
41 EXPECT_FALSE(Provider::ShouldInstallInProfile(profile.get()));
42 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState);
43 EXPECT_TRUE(state == default_apps::kNeverInstallDefaultApps);
44
45 // The old default apps with kAlwaysInstallDefaultAppss should be migrated.
46 profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState,
47 default_apps::kProvideLegacyDefaultApps);
48 EXPECT_TRUE(Provider::ShouldInstallInProfile(profile.get()));
49 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState);
50 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps);
51
52 class DefaultTestingProfile : public TestingProfile {
53 virtual bool WasCreatedByVersionOrLater(
54 const std::string& version) OVERRIDE {
55 return false;
56 }
57 };
58 profile.reset(new DefaultTestingProfile);
59 // The old default apps with kProvideLegacyDefaultApps should be migrated
60 // even if the profile version is older than Chrome version.
61 profile->GetPrefs()->SetInteger(prefs::kDefaultAppsInstallState,
62 default_apps::kProvideLegacyDefaultApps);
63 EXPECT_TRUE(Provider::ShouldInstallInProfile(profile.get()));
64 state = profile->GetPrefs()->GetInteger(prefs::kDefaultAppsInstallState);
65 EXPECT_TRUE(state == default_apps::kAlreadyInstalledDefaultApps);
66 }
67 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698