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

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

Issue 10107014: Migrate WebKit "global script" font prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 8 years, 7 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "chrome/browser/prefs/pref_service.h" 7 #include "chrome/browser/prefs/pref_service.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/common/chrome_constants.h" 10 #include "chrome/common/chrome_constants.h"
11 #include "chrome/common/chrome_paths.h" 11 #include "chrome/common/chrome_paths.h"
12 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
13 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
14 14
15 class PrefsTabHelperBrowserTest : public InProcessBrowserTest { 15 class PrefsTabHelperBrowserTest2 : public InProcessBrowserTest {
16 protected: 16 protected:
17 virtual bool SetUpUserDataDirectory() OVERRIDE { 17 virtual bool SetUpUserDataDirectory() OVERRIDE {
18 FilePath test_data_directory; 18 FilePath test_data_directory;
19 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory); 19 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory);
20 FilePath user_data_directory; 20 FilePath user_data_directory;
21 PathService::Get(chrome::DIR_USER_DATA, &user_data_directory); 21 PathService::Get(chrome::DIR_USER_DATA, &user_data_directory);
22 FilePath default_profile = user_data_directory.AppendASCII("Default"); 22 FilePath default_profile = user_data_directory.AppendASCII("Default");
23 if (!file_util::CreateDirectory(default_profile)) { 23 if (!file_util::CreateDirectory(default_profile)) {
24 LOG(ERROR) << "Can't create " << default_profile.MaybeAsASCII(); 24 LOG(ERROR) << "Can't create " << default_profile.MaybeAsASCII();
25 return false; 25 return false;
26 } 26 }
27 FilePath non_global_pref_file; 27 FilePath non_global_pref_file;
28 non_global_pref_file = test_data_directory 28 non_global_pref_file = test_data_directory
29 .AppendASCII("profiles") 29 .AppendASCII("profiles")
30 .AppendASCII("webkit_global_migration") 30 .AppendASCII("webkit_global_reverse_migration")
tony 2012/05/09 17:11:15 E.g., you could have PrefsTabHelperBrowserTest2 in
falken 2012/05/11 11:04:14 OK I see. Done.
31 .AppendASCII("Default") 31 .AppendASCII("Default")
32 .Append(chrome::kPreferencesFilename); 32 .Append(chrome::kPreferencesFilename);
33 if (!file_util::PathExists(non_global_pref_file)) { 33 if (!file_util::PathExists(non_global_pref_file)) {
34 LOG(ERROR) << "Doesn't exist " << non_global_pref_file.MaybeAsASCII(); 34 LOG(ERROR) << "Doesn't exist " << non_global_pref_file.MaybeAsASCII();
35 return false; 35 return false;
36 } 36 }
37 FilePath default_pref_file = 37 FilePath default_pref_file =
38 default_profile.Append(chrome::kPreferencesFilename); 38 default_profile.Append(chrome::kPreferencesFilename);
39 if (!file_util::CopyFile(non_global_pref_file, default_pref_file)) { 39 if (!file_util::CopyFile(non_global_pref_file, default_pref_file)) {
40 LOG(ERROR) << "Copy error from " << non_global_pref_file.MaybeAsASCII() 40 LOG(ERROR) << "Copy error from " << non_global_pref_file.MaybeAsASCII()
41 << " to " << default_pref_file.MaybeAsASCII(); 41 << " to " << default_pref_file.MaybeAsASCII();
42 return false; 42 return false;
43 } 43 }
44 44
45 #if defined(OS_WIN) 45 #if defined(OS_WIN)
46 // Make the copy writable. On POSIX we assume the umask allows files 46 // Make the copy writable. On POSIX we assume the umask allows files
47 // we create to be writable. 47 // we create to be writable.
48 if (!::SetFileAttributesW(default_pref_file.value().c_str(), 48 if (!::SetFileAttributesW(default_pref_file.value().c_str(),
49 FILE_ATTRIBUTE_NORMAL)) return false; 49 FILE_ATTRIBUTE_NORMAL)) return false;
50 #endif 50 #endif
51 return true; 51 return true;
52 } 52 }
53 }; 53 };
54 54
55 IN_PROC_BROWSER_TEST_F(PrefsTabHelperBrowserTest, NonGlobalPrefsAreMigrated) { 55 IN_PROC_BROWSER_TEST_F(PrefsTabHelperBrowserTest2, GlobalPrefsAreMigrated) {
56 PrefService* prefs = browser()->profile()->GetPrefs(); 56 PrefService* prefs = browser()->profile()->GetPrefs();
57 57
58 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kDefaultCharset)); 58 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitGlobalCursiveFontFamily));
59 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitDefaultFontSize)); 59 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitGlobalFantasyFontFamily));
60 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitDefaultFixedFontSize)); 60 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitGlobalFixedFontFamily));
61 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitMinimumFontSize)); 61 EXPECT_EQ(NULL,
62 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitMinimumLogicalFontSize)); 62 prefs->FindPreference(prefs::kWebKitGlobalSansSerifFontFamily));
63 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitCursiveFontFamily)); 63 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitGlobalSerifFontFamily));
64 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitFantasyFontFamily)); 64 EXPECT_EQ(NULL,
65 EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitFixedFontFamily)); 65 prefs->FindPreference(prefs::kWebKitGlobalStandardFontFamily));
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 66
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", 67 EXPECT_EQ("CursiveFontFamily",
78 prefs->GetString(prefs::kWebKitGlobalCursiveFontFamily)); 68 prefs->GetString(prefs::kWebKitCursiveFontFamily));
79 EXPECT_EQ("FantasyFontFamily", 69 EXPECT_EQ("FantasyFontFamily",
80 prefs->GetString(prefs::kWebKitGlobalFantasyFontFamily)); 70 prefs->GetString(prefs::kWebKitFantasyFontFamily));
81 EXPECT_EQ("FixedFontFamily", 71 EXPECT_EQ("FixedFontFamily",
82 prefs->GetString(prefs::kWebKitGlobalFixedFontFamily)); 72 prefs->GetString(prefs::kWebKitFixedFontFamily));
83 EXPECT_EQ("SansSerifFontFamily", 73 EXPECT_EQ("SansSerifFontFamily",
84 prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily)); 74 prefs->GetString(prefs::kWebKitSansSerifFontFamily));
85 EXPECT_EQ("SerifFontFamily", 75 EXPECT_EQ("SerifFontFamily",
86 prefs->GetString(prefs::kWebKitGlobalSerifFontFamily)); 76 prefs->GetString(prefs::kWebKitSerifFontFamily));
87 EXPECT_EQ("StandardFontFamily", 77 EXPECT_EQ("StandardFontFamily",
88 prefs->GetString(prefs::kWebKitGlobalStandardFontFamily)); 78 prefs->GetString(prefs::kWebKitStandardFontFamily));
89 } 79 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698