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

Unified Diff: ui/gfx/platform_font_mac_unittest.mm

Issue 2222483002: Mac: Fix PlatformFontMac::DeriveFont. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@font_mac
Patch Set: Created 4 years, 4 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/platform_font_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/platform_font_mac_unittest.mm
diff --git a/ui/gfx/platform_font_mac_unittest.mm b/ui/gfx/platform_font_mac_unittest.mm
index 362bed44a6fdc67f320af4edeb5ec5d7e77c0493..e65b8b1fd95e1249e00bbcc89c99b7dfa5230e43 100644
--- a/ui/gfx/platform_font_mac_unittest.mm
+++ b/ui/gfx/platform_font_mac_unittest.mm
@@ -36,6 +36,30 @@
traits);
}
+TEST(PlatformFontMacTest, DeriveFontUnderline) {
+ // Create a default font.
+ gfx::Font base_font;
+
+ // Make the font underlined.
+ gfx::Font derived_font(base_font.Derive(
+ 0, base_font.GetStyle() | gfx::Font::UNDERLINE, base_font.GetWeight()));
+
+ // Validate the derived font properties against its native font instance.
+ NSFontTraitMask traits = [[NSFontManager sharedFontManager]
+ traitsOfFont:derived_font.GetNativeFont()];
+ gfx::Font::Weight actual_weight = (traits & NSFontBoldTrait)
+ ? gfx::Font::Weight::BOLD
+ : gfx::Font::Weight::NORMAL;
+
+ int actual_style = gfx::Font::UNDERLINE;
+ if (traits & NSFontItalicTrait)
+ actual_style |= gfx::Font::ITALIC;
+
+ EXPECT_TRUE(derived_font.GetStyle() & gfx::Font::UNDERLINE);
+ EXPECT_EQ(derived_font.GetStyle(), actual_style);
+ EXPECT_EQ(derived_font.GetWeight(), actual_weight);
+}
+
TEST(PlatformFontMacTest, ConstructFromNativeFont) {
gfx::Font normal_font([NSFont fontWithName:@"Helvetica" size:12]);
EXPECT_EQ(12, normal_font.GetFontSize());
« no previous file with comments | « ui/gfx/platform_font_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698