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

Unified Diff: ui/gfx/font_render_params_linux_unittest.cc

Issue 403923002: Make GetCustomFontRenderParams() pass font style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: apply review feedback Created 6 years, 5 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
« no previous file with comments | « ui/gfx/font_render_params_linux.cc ('k') | ui/gfx/font_render_params_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/font_render_params_linux_unittest.cc
diff --git a/ui/gfx/font_render_params_linux_unittest.cc b/ui/gfx/font_render_params_linux_unittest.cc
index d46764578b1b5b9c2382b1fba84660bcc4b8e982..1a9167f069666a70ae94c09fb69246e3e68abfba 100644
--- a/ui/gfx/font_render_params_linux_unittest.cc
+++ b/ui/gfx/font_render_params_linux_unittest.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/font.h"
#include "ui/gfx/test/fontconfig_util_linux.h"
namespace gfx {
@@ -72,7 +73,6 @@ TEST_F(FontRenderParamsTest, Default) {
}
TEST_F(FontRenderParamsTest, Size) {
- // Fontconfig needs to know about at least one font to return a match.
ASSERT_TRUE(LoadSystemFont("arial.ttf"));
ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(),
std::string(kFontconfigFileHeader) +
@@ -97,25 +97,73 @@ TEST_F(FontRenderParamsTest, Size) {
// second or third blocks.
int pixel_size = 12;
FontRenderParams params = GetCustomFontRenderParams(
- false, NULL, &pixel_size, NULL, NULL);
+ false, NULL, &pixel_size, NULL, NULL, NULL);
EXPECT_TRUE(params.antialiasing);
EXPECT_EQ(FontRenderParams::HINTING_FULL, params.hinting);
EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE,
params.subpixel_rendering);
pixel_size = 10;
- params = GetCustomFontRenderParams(false, NULL, &pixel_size, NULL, NULL);
+ params = GetCustomFontRenderParams(
+ false, NULL, &pixel_size, NULL, NULL, NULL);
EXPECT_FALSE(params.antialiasing);
EXPECT_EQ(FontRenderParams::HINTING_FULL, params.hinting);
EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE,
params.subpixel_rendering);
int point_size = 20;
- params = GetCustomFontRenderParams(false, NULL, NULL, &point_size, NULL);
+ params = GetCustomFontRenderParams(
+ false, NULL, NULL, &point_size, NULL, NULL);
EXPECT_TRUE(params.antialiasing);
EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting);
EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_RGB,
params.subpixel_rendering);
}
+TEST_F(FontRenderParamsTest, Style) {
+ ASSERT_TRUE(LoadSystemFont("arial.ttf"));
+ // Load a config that disables antialiasing for bold text and disables
+ // hinting for italic text.
+ ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(),
+ std::string(kFontconfigFileHeader) +
+ kFontconfigMatchHeader +
+ CreateFontconfigEditStanza("antialias", "bool", "true") +
+ CreateFontconfigEditStanza("hinting", "bool", "true") +
+ CreateFontconfigEditStanza("hintstyle", "const", "hintfull") +
+ kFontconfigMatchFooter +
+ kFontconfigMatchHeader +
+ CreateFontconfigTestStanza("weight", "eq", "const", "bold") +
+ CreateFontconfigEditStanza("antialias", "bool", "false") +
+ kFontconfigMatchFooter +
+ kFontconfigMatchHeader +
+ CreateFontconfigTestStanza("slant", "eq", "const", "italic") +
+ CreateFontconfigEditStanza("hinting", "bool", "false") +
+ kFontconfigMatchFooter +
+ kFontconfigFileFooter));
+
+ int style = Font::NORMAL;
+ FontRenderParams params = GetCustomFontRenderParams(
+ false, NULL, NULL, NULL, &style, NULL);
+ EXPECT_TRUE(params.antialiasing);
+ EXPECT_EQ(FontRenderParams::HINTING_FULL, params.hinting);
+
+ style = Font::BOLD;
+ params = GetCustomFontRenderParams(
+ false, NULL, NULL, NULL, &style, NULL);
+ EXPECT_FALSE(params.antialiasing);
+ EXPECT_EQ(FontRenderParams::HINTING_FULL, params.hinting);
+
+ style = Font::ITALIC;
+ params = GetCustomFontRenderParams(
+ false, NULL, NULL, NULL, &style, NULL);
+ EXPECT_TRUE(params.antialiasing);
+ EXPECT_EQ(FontRenderParams::HINTING_NONE, params.hinting);
+
+ style = Font::BOLD | Font::ITALIC;
+ params = GetCustomFontRenderParams(
+ false, NULL, NULL, NULL, &style, NULL);
+ EXPECT_FALSE(params.antialiasing);
+ EXPECT_EQ(FontRenderParams::HINTING_NONE, params.hinting);
+}
+
} // namespace gfx
« no previous file with comments | « ui/gfx/font_render_params_linux.cc ('k') | ui/gfx/font_render_params_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698