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

Side by Side Diff: chrome/browser/protector/prefs_backup_invalid_change_unittest.cc

Issue 11493003: Remove the protector service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix implicit ExtensionSystem -> TemplateURLService dependency Created 8 years 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/prefs/pref_service.h"
7 #include "chrome/browser/prefs/session_startup_pref.h"
8 #include "chrome/browser/protector/base_setting_change.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 #if defined(OS_MACOSX)
14 #include "base/mac/mac_util.h"
15 #endif
16
17 namespace protector {
18
19 namespace {
20
21 const char kStartupUrl[] = "http://example.com/";
22
23 } // namespace
24
25 class PrefsBackupInvalidChangeTest : public testing::Test {
26 protected:
27 virtual void SetUp() OVERRIDE {
28 // Make the tests independent of the Mac startup pref migration (see
29 // SessionStartupPref::MigrateMacDefaultPrefIfNecessary).
30 PrefService* prefs = profile_.GetPrefs();
31 prefs->SetString(prefs::kProfileCreatedByVersion, "22.0.0.0.0");
32 }
33
34 TestingProfile profile_;
35 };
36
37 // Test that correct default values are applied by Init.
38 TEST_F(PrefsBackupInvalidChangeTest, Defaults) {
39 SessionStartupPref startup_pref(SessionStartupPref::URLS);
40 startup_pref.urls.push_back(GURL(kStartupUrl));
41 SessionStartupPref::SetStartupPref(&profile_, startup_pref);
42
43 scoped_ptr<BaseSettingChange> change(CreatePrefsBackupInvalidChange());
44 change->Init(&profile_);
45
46 SessionStartupPref new_startup_pref =
47 SessionStartupPref::GetStartupPref(&profile_);
48 // Startup type should be reset to default.
49 EXPECT_EQ(SessionStartupPref::GetDefaultStartupType(), new_startup_pref.type);
50 // Startup URLs should be left unchanged.
51 EXPECT_EQ(1UL, new_startup_pref.urls.size());
52 EXPECT_EQ(std::string(kStartupUrl), new_startup_pref.urls[0].spec());
53 // Homepage prefs are reset to defaults.
54 PrefService* prefs = profile_.GetPrefs();
55 EXPECT_FALSE(prefs->HasPrefPath(prefs::kHomePageIsNewTabPage));
56 EXPECT_FALSE(prefs->HasPrefPath(prefs::kHomePage));
57 EXPECT_FALSE(prefs->HasPrefPath(prefs::kShowHomeButton));
58 }
59
60 // Test that "restore last session" setting is not changed by Init.
61 TEST_F(PrefsBackupInvalidChangeTest, DefaultsWithSessionRestore) {
62 SessionStartupPref startup_pref(SessionStartupPref::LAST);
63 startup_pref.urls.push_back(GURL(kStartupUrl));
64 SessionStartupPref::SetStartupPref(&profile_, startup_pref);
65
66 scoped_ptr<BaseSettingChange> change(CreatePrefsBackupInvalidChange());
67 change->Init(&profile_);
68
69 SessionStartupPref new_startup_pref =
70 SessionStartupPref::GetStartupPref(&profile_);
71 // Both startup type and startup URLs should be left unchanged.
72 EXPECT_EQ(SessionStartupPref::LAST, new_startup_pref.type);
73 EXPECT_EQ(1UL, new_startup_pref.urls.size());
74 EXPECT_EQ(std::string(kStartupUrl), new_startup_pref.urls[0].spec());
75 }
76
77 } // namespace protector
OLDNEW
« no previous file with comments | « chrome/browser/protector/prefs_backup_invalid_change.cc ('k') | chrome/browser/protector/protected_prefs_watcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698