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

Side by Side Diff: chrome/browser/ui/prefs/prefs_tab_helper_browsertest.cc

Issue 8879016: Add more per-tab preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CHECK -> DCHECK Created 8 years, 11 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) 2011 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/file_util.h"
6 #include "base/path_service.h"
7 #include "chrome/browser/prefs/pref_service.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/common/chrome_constants.h"
11 #include "chrome/common/chrome_paths.h"
12 #include "chrome/common/pref_names.h"
13 #include "chrome/test/base/in_process_browser_test.h"
14
15 class PrefsTabHelperBrowserTest : public InProcessBrowserTest {
16 protected:
17 virtual bool SetUpUserDataDirectory() OVERRIDE {
18 FilePath test_data_directory;
19 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory);
20 FilePath user_data_directory;
21 PathService::Get(chrome::DIR_USER_DATA, &user_data_directory);
22 FilePath default_profile = user_data_directory.AppendASCII("Default");
23 if (!file_util::CreateDirectory(default_profile)) {
24 LOG(ERROR) << "Can't create " << default_profile.MaybeAsASCII();
25 return false;
26 }
27 FilePath non_global_pref_file;
28 non_global_pref_file = test_data_directory
29 .AppendASCII("profiles")
30 .AppendASCII("webkit_global_migration")
31 .AppendASCII("Default")
32 .Append(chrome::kPreferencesFilename);
33 if (!file_util::PathExists(non_global_pref_file)) {
34 LOG(ERROR) << "Doesn't exist " << non_global_pref_file.MaybeAsASCII();
35 return false;
36 }
37 FilePath default_pref_file =
38 default_profile.Append(chrome::kPreferencesFilename);
39 if (!file_util::CopyFile(non_global_pref_file, default_pref_file)) {
40 LOG(ERROR) << "Copy error from " << non_global_pref_file.MaybeAsASCII()
41 << " to " << default_pref_file.MaybeAsASCII();
42 return false;
43 }
44
45 #if defined(OS_WIN)
46 // Make the copy writable. On POSIX we assume the umask allows files
47 // we create to be writable.
48 if (!::SetFileAttributesW(default_pref_file.value().c_str(),
49 FILE_ATTRIBUTE_NORMAL)) return false;
50 #endif
51 return true;
52 }
53 };
54
55 IN_PROC_BROWSER_TEST_F(PrefsTabHelperBrowserTest, NonGlobalPrefsAreMigrated) {
56 PrefService* prefs = browser()->profile()->GetPrefs();
57
58 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kDefaultCharset));
59 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitDefaultFontSize));
60 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitDefaultFixedFontSize));
61 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitMinimumFontSize));
62 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitMinimumLogicalFontSize));
63 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitCursiveFontFamily));
64 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitFantasyFontFamily));
65 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitFixedFontFamily));
66 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitSansSerifFontFamily));
67 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitSerifFontFamily));
68 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitStandardFontFamily));
69
70 EXPECT_EQ("ISO-8859-1", prefs->GetString(prefs::kGlobalDefaultCharset));
71 EXPECT_EQ(42, prefs->GetInteger(prefs::kWebKitGlobalDefaultFontSize));
72 EXPECT_EQ(42,
73 prefs->GetInteger(prefs::kWebKitGlobalDefaultFixedFontSize));
74 EXPECT_EQ(42, prefs->GetInteger(prefs::kWebKitGlobalMinimumFontSize));
75 EXPECT_EQ(42,
76 prefs->GetInteger(prefs::kWebKitGlobalMinimumLogicalFontSize));
77 EXPECT_EQ("CursiveFontFamily",
78 prefs->GetString(prefs::kWebKitGlobalCursiveFontFamily));
79 EXPECT_EQ("FantasyFontFamily",
80 prefs->GetString(prefs::kWebKitGlobalFantasyFontFamily));
81 EXPECT_EQ("FixedFontFamily",
82 prefs->GetString(prefs::kWebKitGlobalFixedFontFamily));
83 EXPECT_EQ("SansSerifFontFamily",
84 prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily));
85 EXPECT_EQ("SerifFontFamily",
86 prefs->GetString(prefs::kWebKitGlobalSerifFontFamily));
87 EXPECT_EQ("StandardFontFamily",
88 prefs->GetString(prefs::kWebKitGlobalStandardFontFamily));
89 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/prefs/prefs_tab_helper.cc ('k') | chrome/browser/ui/prefs/prefs_tab_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698