summaryrefslogtreecommitdiffstats
path: root/chromium/ui/gfx/font_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/gfx/font_unittest.cc')
-rw-r--r--chromium/ui/gfx/font_unittest.cc46
1 files changed, 19 insertions, 27 deletions
diff --git a/chromium/ui/gfx/font_unittest.cc b/chromium/ui/gfx/font_unittest.cc
index 2fdaab872f4..da4bdfcc4bd 100644
--- a/chromium/ui/gfx/font_unittest.cc
+++ b/chromium/ui/gfx/font_unittest.cc
@@ -70,7 +70,7 @@ TEST_F(FontTest, LoadArial) {
TEST_F(FontTest, LoadArialBold) {
Font cf("Arial", 16);
- Font bold(cf.DeriveFont(0, Font::BOLD));
+ Font bold(cf.Derive(0, Font::BOLD));
NativeFont native = bold.GetNativeFont();
EXPECT_TRUE(native);
EXPECT_EQ(bold.GetStyle(), Font::BOLD);
@@ -95,11 +95,7 @@ TEST_F(FontTest, CapHeight) {
Font cf("Arial", 16);
EXPECT_GT(cf.GetCapHeight(), 0);
EXPECT_GT(cf.GetCapHeight(), cf.GetHeight() / 2);
-#if defined(OS_CHROMEOS) || defined(OS_LINUX)
- EXPECT_EQ(cf.GetCapHeight(), cf.GetBaseline());
-#else
EXPECT_LT(cf.GetCapHeight(), cf.GetBaseline());
-#endif
}
TEST_F(FontTest, AvgWidths) {
@@ -110,30 +106,26 @@ TEST_F(FontTest, AvgWidths) {
EXPECT_GT(cf.GetExpectedTextWidth(3), cf.GetExpectedTextWidth(2));
}
-TEST_F(FontTest, AvgCharWidth) {
- Font cf("Arial", 16);
- EXPECT_GT(cf.GetAverageCharacterWidth(), 0);
-}
-
-TEST_F(FontTest, Widths) {
- Font cf("Arial", 16);
- EXPECT_EQ(cf.GetStringWidth(base::string16()), 0);
- EXPECT_GT(cf.GetStringWidth(ASCIIToUTF16("a")),
- cf.GetStringWidth(base::string16()));
- EXPECT_GT(cf.GetStringWidth(ASCIIToUTF16("ab")),
- cf.GetStringWidth(ASCIIToUTF16("a")));
- EXPECT_GT(cf.GetStringWidth(ASCIIToUTF16("abc")),
- cf.GetStringWidth(ASCIIToUTF16("ab")));
-}
-
#if !defined(OS_WIN)
// On Windows, Font::GetActualFontNameForTesting() doesn't work well for now.
// http://crbug.com/327287
+//
+// Check that fonts used for testing are installed and enabled. On Mac
+// fonts may be installed but still need enabling in Font Book.app.
+// http://crbug.com/347429
TEST_F(FontTest, GetActualFontNameForTesting) {
Font arial("Arial", 16);
- EXPECT_EQ("arial", StringToLowerASCII(arial.GetActualFontNameForTesting()));
+ EXPECT_EQ("arial", StringToLowerASCII(arial.GetActualFontNameForTesting()))
+ << "********\n"
+ << "Your test environment seems to be missing Arial font, which is "
+ << "needed for unittests. Check if Arial font is installed.\n"
+ << "********";
Font symbol("Symbol", 16);
- EXPECT_EQ("symbol", StringToLowerASCII(symbol.GetActualFontNameForTesting()));
+ EXPECT_EQ("symbol", StringToLowerASCII(symbol.GetActualFontNameForTesting()))
+ << "********\n"
+ << "Your test environment seems to be missing Symbol font, which is "
+ << "needed for unittests. Check if Symbol font is installed.\n"
+ << "********";
const char* const invalid_font_name = "no_such_font_name";
Font fallback_font(invalid_font_name, 16);
@@ -143,21 +135,21 @@ TEST_F(FontTest, GetActualFontNameForTesting) {
#endif
#if defined(OS_WIN)
-TEST_F(FontTest, DeriveFontResizesIfSizeTooSmall) {
+TEST_F(FontTest, DeriveResizesIfSizeTooSmall) {
Font cf("Arial", 8);
// The minimum font size is set to 5 in browser_main.cc.
ScopedMinimumFontSizeCallback minimum_size(5);
- Font derived_font = cf.DeriveFont(-4);
+ Font derived_font = cf.Derive(-4, cf.GetStyle());
EXPECT_EQ(5, derived_font.GetFontSize());
}
-TEST_F(FontTest, DeriveFontKeepsOriginalSizeIfHeightOk) {
+TEST_F(FontTest, DeriveKeepsOriginalSizeIfHeightOk) {
Font cf("Arial", 8);
// The minimum font size is set to 5 in browser_main.cc.
ScopedMinimumFontSizeCallback minimum_size(5);
- Font derived_font = cf.DeriveFont(-2);
+ Font derived_font = cf.Derive(-2, cf.GetStyle());
EXPECT_EQ(6, derived_font.GetFontSize());
}
#endif // defined(OS_WIN)