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

Unified Diff: chrome/browser/ui/prefs/prefs_tab_helper_browsertest.cc

Issue 10107014: Migrate WebKit "global script" font prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/prefs/prefs_tab_helper_browsertest.cc
diff --git a/chrome/browser/ui/prefs/prefs_tab_helper_browsertest.cc b/chrome/browser/ui/prefs/prefs_tab_helper_browsertest.cc
index 890a33ae8faf46ba87d97c273dd3f89e90593be6..ba7a54f2f70bd6d09124f4c05a66c7728b7b5770 100644
--- a/chrome/browser/ui/prefs/prefs_tab_helper_browsertest.cc
+++ b/chrome/browser/ui/prefs/prefs_tab_helper_browsertest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,9 +14,17 @@
class PrefsTabHelperBrowserTest : public InProcessBrowserTest {
protected:
- virtual bool SetUpUserDataDirectory() OVERRIDE {
+ virtual FilePath GetPreferencesFilePath() {
FilePath test_data_directory;
PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory);
+ return test_data_directory
+ .AppendASCII("profiles")
+ .AppendASCII("webkit_global_migration")
+ .AppendASCII("Default")
+ .Append(chrome::kPreferencesFilename);
+ }
+
+ virtual bool SetUpUserDataDirectory() OVERRIDE {
FilePath user_data_directory;
PathService::Get(chrome::DIR_USER_DATA, &user_data_directory);
FilePath default_profile = user_data_directory.AppendASCII("Default");
@@ -24,12 +32,7 @@ class PrefsTabHelperBrowserTest : public InProcessBrowserTest {
LOG(ERROR) << "Can't create " << default_profile.MaybeAsASCII();
return false;
}
- FilePath non_global_pref_file;
- non_global_pref_file = test_data_directory
- .AppendASCII("profiles")
- .AppendASCII("webkit_global_migration")
- .AppendASCII("Default")
- .Append(chrome::kPreferencesFilename);
+ FilePath non_global_pref_file = GetPreferencesFilePath();
if (!file_util::PathExists(non_global_pref_file)) {
LOG(ERROR) << "Doesn't exist " << non_global_pref_file.MaybeAsASCII();
return false;
@@ -52,6 +55,10 @@ class PrefsTabHelperBrowserTest : public InProcessBrowserTest {
}
};
+// This tests migration like:
+// webkit.webprefs.default_charset -> webkit.webprefs.global.default_charset
+// This was needed for per-tab prefs, which have since been removed. So
+// eventually this migration will be replaced with the reverse migration.
IN_PROC_BROWSER_TEST_F(PrefsTabHelperBrowserTest, NonGlobalPrefsAreMigrated) {
PrefService* prefs = browser()->profile()->GetPrefs();
@@ -60,12 +67,6 @@ IN_PROC_BROWSER_TEST_F(PrefsTabHelperBrowserTest, NonGlobalPrefsAreMigrated) {
EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitDefaultFixedFontSize));
EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitMinimumFontSize));
EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitMinimumLogicalFontSize));
- EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitCursiveFontFamily));
- EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitFantasyFontFamily));
- EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitFixedFontFamily));
- EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitSansSerifFontFamily));
- EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitSerifFontFamily));
- EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitStandardFontFamily));
EXPECT_EQ("ISO-8859-1", prefs->GetString(prefs::kGlobalDefaultCharset));
EXPECT_EQ(42, prefs->GetInteger(prefs::kWebKitGlobalDefaultFontSize));
@@ -74,16 +75,78 @@ IN_PROC_BROWSER_TEST_F(PrefsTabHelperBrowserTest, NonGlobalPrefsAreMigrated) {
EXPECT_EQ(42, prefs->GetInteger(prefs::kWebKitGlobalMinimumFontSize));
EXPECT_EQ(42,
prefs->GetInteger(prefs::kWebKitGlobalMinimumLogicalFontSize));
+};
+
+// This tests migration like:
+// webkit.webprefs.standard_font_family -> webkit.webprefs.fonts.standard.Zyyy
+// This migration moves the formerly "non-per-script" font prefs into the
+// per-script font maps, as the entry for "Common" script (Zyyy is the ISO 15924
+// script code for the Common script).
+IN_PROC_BROWSER_TEST_F(PrefsTabHelperBrowserTest, PrefsAreMigratedToFontMap) {
+ PrefService* prefs = browser()->profile()->GetPrefs();
+
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitOldCursiveFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitOldFantasyFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitOldFixedFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitOldSansSerifFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitOldSerifFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitOldStandardFontFamily));
EXPECT_EQ("CursiveFontFamily",
- prefs->GetString(prefs::kWebKitGlobalCursiveFontFamily));
+ prefs->GetString(prefs::kWebKitCursiveFontFamily));
EXPECT_EQ("FantasyFontFamily",
- prefs->GetString(prefs::kWebKitGlobalFantasyFontFamily));
+ prefs->GetString(prefs::kWebKitFantasyFontFamily));
EXPECT_EQ("FixedFontFamily",
- prefs->GetString(prefs::kWebKitGlobalFixedFontFamily));
+ prefs->GetString(prefs::kWebKitFixedFontFamily));
EXPECT_EQ("SansSerifFontFamily",
- prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily));
+ prefs->GetString(prefs::kWebKitSansSerifFontFamily));
EXPECT_EQ("SerifFontFamily",
- prefs->GetString(prefs::kWebKitGlobalSerifFontFamily));
+ prefs->GetString(prefs::kWebKitSerifFontFamily));
EXPECT_EQ("StandardFontFamily",
- prefs->GetString(prefs::kWebKitGlobalStandardFontFamily));
-}
+ prefs->GetString(prefs::kWebKitStandardFontFamily));
+};
+
+class PrefsTabHelperBrowserTest2 : public PrefsTabHelperBrowserTest {
+ protected:
+ virtual FilePath GetPreferencesFilePath() OVERRIDE {
+ FilePath test_data_directory;
+ PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory);
+ return test_data_directory
+ .AppendASCII("profiles")
+ .AppendASCII("webkit_global_reverse_migration")
+ .AppendASCII("Default")
+ .Append(chrome::kPreferencesFilename);
+ }
+};
+
+// This tests migration like:
+// webkit.webprefs.global.standard_font_family ->
+// webkit.webprefs.fonts.standard.Zyyy
+// This undoes the migration to "global" names (originally done for the per-tab
+// pref mechanism, which has since been removed). In addition, it moves the
+// formerly "non-per-script" font prefs into the per-script font maps, as
+// described in the comment for PrefsAreMigratedToFontMap.
+IN_PROC_BROWSER_TEST_F(PrefsTabHelperBrowserTest2, GlobalPrefsAreMigrated) {
+ PrefService* prefs = browser()->profile()->GetPrefs();
+
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitGlobalCursiveFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitGlobalFantasyFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitGlobalFixedFontFamily));
+ EXPECT_EQ(NULL,
+ prefs->FindPreference(prefs::kWebKitGlobalSansSerifFontFamily));
+ EXPECT_EQ(NULL, prefs->FindPreference(prefs::kWebKitGlobalSerifFontFamily));
+ EXPECT_EQ(NULL,
+ prefs->FindPreference(prefs::kWebKitGlobalStandardFontFamily));
+
+ EXPECT_EQ("CursiveFontFamily",
+ prefs->GetString(prefs::kWebKitCursiveFontFamily));
+ EXPECT_EQ("FantasyFontFamily",
+ prefs->GetString(prefs::kWebKitFantasyFontFamily));
+ EXPECT_EQ("FixedFontFamily",
+ prefs->GetString(prefs::kWebKitFixedFontFamily));
+ EXPECT_EQ("SansSerifFontFamily",
+ prefs->GetString(prefs::kWebKitSansSerifFontFamily));
+ EXPECT_EQ("SerifFontFamily",
+ prefs->GetString(prefs::kWebKitSerifFontFamily));
+ EXPECT_EQ("StandardFontFamily",
+ prefs->GetString(prefs::kWebKitStandardFontFamily));
+};
« no previous file with comments | « chrome/browser/ui/prefs/prefs_tab_helper.cc ('k') | chrome/browser/ui/webui/options2/font_settings_handler2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698