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

Side by Side Diff: ui/gfx/font_render_params_linux_unittest.cc

Issue 811123002: linux/chromeos: Improve querying for Fontconfig defaults. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert expectation reordering Created 5 years, 12 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
« no previous file with comments | « ui/gfx/font_render_params_linux.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/gfx/font_render_params.h" 5 #include "ui/gfx/font_render_params.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 29 matching lines...) Expand all
40 return 96.0; 40 return 96.0;
41 } 41 }
42 42
43 private: 43 private:
44 FontRenderParams params_; 44 FontRenderParams params_;
45 45
46 DISALLOW_COPY_AND_ASSIGN(TestFontDelegate); 46 DISALLOW_COPY_AND_ASSIGN(TestFontDelegate);
47 }; 47 };
48 48
49 // Loads the first system font defined by fontconfig_util_linux.h with a base 49 // Loads the first system font defined by fontconfig_util_linux.h with a base
50 // filename of |basename|. Case is ignored. 50 // filename of |basename|. Case is ignored. FcFontMatch() requires there to be
51 // at least one font present.
51 bool LoadSystemFont(const std::string& basename) { 52 bool LoadSystemFont(const std::string& basename) {
52 for (size_t i = 0; i < kNumSystemFontsForFontconfig; ++i) { 53 for (size_t i = 0; i < kNumSystemFontsForFontconfig; ++i) {
53 base::FilePath path(gfx::kSystemFontsForFontconfig[i]); 54 base::FilePath path(gfx::kSystemFontsForFontconfig[i]);
54 if (strcasecmp(path.BaseName().value().c_str(), basename.c_str()) == 0) 55 if (strcasecmp(path.BaseName().value().c_str(), basename.c_str()) == 0)
55 return LoadFontIntoFontconfig(path); 56 return LoadFontIntoFontconfig(path);
56 } 57 }
57 LOG(ERROR) << "Unable to find system font named " << basename; 58 LOG(ERROR) << "Unable to find system font named " << basename;
58 return false; 59 return false;
59 } 60 }
60 61
(...skipping 21 matching lines...) Expand all
82 TestFontDelegate test_font_delegate_; 83 TestFontDelegate test_font_delegate_;
83 84
84 private: 85 private:
85 DISALLOW_COPY_AND_ASSIGN(FontRenderParamsTest); 86 DISALLOW_COPY_AND_ASSIGN(FontRenderParamsTest);
86 }; 87 };
87 88
88 TEST_F(FontRenderParamsTest, Default) { 89 TEST_F(FontRenderParamsTest, Default) {
89 ASSERT_TRUE(LoadSystemFont("arial.ttf")); 90 ASSERT_TRUE(LoadSystemFont("arial.ttf"));
90 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), 91 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(),
91 std::string(kFontconfigFileHeader) + 92 std::string(kFontconfigFileHeader) +
92 kFontconfigMatchPatternHeader + 93 // Specify the desired defaults via a font match rather than a pattern
94 // match (since this is the style generally used in /etc/fonts/conf.d).
95 kFontconfigMatchFontHeader +
93 CreateFontconfigEditStanza("antialias", "bool", "true") + 96 CreateFontconfigEditStanza("antialias", "bool", "true") +
94 CreateFontconfigEditStanza("autohint", "bool", "true") + 97 CreateFontconfigEditStanza("autohint", "bool", "true") +
95 CreateFontconfigEditStanza("hinting", "bool", "true") + 98 CreateFontconfigEditStanza("hinting", "bool", "true") +
96 CreateFontconfigEditStanza("hintstyle", "const", "hintslight") + 99 CreateFontconfigEditStanza("hintstyle", "const", "hintslight") +
97 CreateFontconfigEditStanza("rgba", "const", "rgb") + 100 CreateFontconfigEditStanza("rgba", "const", "rgb") +
98 kFontconfigMatchFooter + 101 kFontconfigMatchFooter +
99 // Add a font match for Arial; it shouldn't be used when querying for 102 // Add a font match for Arial. Since it specifies a family, it shouldn't
100 // default settings: http://crbug.com/421247 103 // take effect when querying default settings.
101 kFontconfigMatchFontHeader + 104 kFontconfigMatchFontHeader +
102 CreateFontconfigTestStanza("family", "eq", "string", "Arial") + 105 CreateFontconfigTestStanza("family", "eq", "string", "Arial") +
103 CreateFontconfigEditStanza("antialias", "bool", "true") + 106 CreateFontconfigEditStanza("antialias", "bool", "true") +
104 CreateFontconfigEditStanza("autohint", "bool", "false") + 107 CreateFontconfigEditStanza("autohint", "bool", "false") +
105 CreateFontconfigEditStanza("hinting", "bool", "true") + 108 CreateFontconfigEditStanza("hinting", "bool", "true") +
106 CreateFontconfigEditStanza("hintstyle", "const", "hintfull") + 109 CreateFontconfigEditStanza("hintstyle", "const", "hintfull") +
110 CreateFontconfigEditStanza("rgba", "const", "none") +
107 kFontconfigMatchFooter + 111 kFontconfigMatchFooter +
108 kFontconfigFileFooter)); 112 kFontconfigFileFooter));
109 113
110 FontRenderParams params = GetFontRenderParams( 114 FontRenderParams params = GetFontRenderParams(
111 FontRenderParamsQuery(true), NULL); 115 FontRenderParamsQuery(true), NULL);
112 EXPECT_TRUE(params.antialiasing); 116 EXPECT_TRUE(params.antialiasing);
113 EXPECT_TRUE(params.autohinter); 117 EXPECT_TRUE(params.autohinter);
114 EXPECT_TRUE(params.use_bitmaps); 118 EXPECT_TRUE(params.use_bitmaps);
115 EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting); 119 EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting);
116 EXPECT_FALSE(params.subpixel_positioning); 120 EXPECT_FALSE(params.subpixel_positioning);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 EXPECT_EQ("Verdana", suggested_family); 383 EXPECT_EQ("Verdana", suggested_family);
380 384
381 query.families.clear(); 385 query.families.clear();
382 query.families.push_back("Arial"); 386 query.families.push_back("Arial");
383 suggested_family.clear(); 387 suggested_family.clear();
384 GetFontRenderParams(query, &suggested_family); 388 GetFontRenderParams(query, &suggested_family);
385 EXPECT_EQ("Verdana", suggested_family); 389 EXPECT_EQ("Verdana", suggested_family);
386 } 390 }
387 391
388 } // namespace gfx 392 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font_render_params_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698