| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "app/gfx/font.h" | 5 #include "app/gfx/font.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 TEST_F(FontTest, LoadArialBold) { | 24 TEST_F(FontTest, LoadArialBold) { |
| 25 Font cf(Font::CreateFont(L"Arial", 16)); | 25 Font cf(Font::CreateFont(L"Arial", 16)); |
| 26 Font bold(cf.DeriveFont(0, Font::BOLD)); | 26 Font bold(cf.DeriveFont(0, Font::BOLD)); |
| 27 ASSERT_TRUE(bold.nativeFont()); | 27 ASSERT_TRUE(bold.nativeFont()); |
| 28 ASSERT_EQ(bold.style(), Font::BOLD); | 28 ASSERT_EQ(bold.style(), Font::BOLD); |
| 29 } | 29 } |
| 30 | 30 |
| 31 TEST_F(FontTest, Ascent) { | 31 TEST_F(FontTest, Ascent) { |
| 32 Font cf(Font::CreateFont(L"Arial", 16)); | 32 Font cf(Font::CreateFont(L"Arial", 16)); |
| 33 ASSERT_GT(cf.baseline(), 2); | 33 ASSERT_GT(cf.baseline(), 2); |
| 34 ASSERT_LE(cf.baseline(), 22); |
| 34 } | 35 } |
| 35 | 36 |
| 36 TEST_F(FontTest, Height) { | 37 TEST_F(FontTest, Height) { |
| 37 Font cf(Font::CreateFont(L"Arial", 16)); | 38 Font cf(Font::CreateFont(L"Arial", 16)); |
| 38 ASSERT_LT(cf.baseline(), 22); | 39 ASSERT_GE(cf.height(), 16); |
| 40 // TODO(akalin): Figure out why height is so large on Linux. |
| 41 ASSERT_LE(cf.height(), 26); |
| 39 } | 42 } |
| 40 | 43 |
| 41 TEST_F(FontTest, AvgWidths) { | 44 TEST_F(FontTest, AvgWidths) { |
| 42 Font cf(Font::CreateFont(L"Arial", 16)); | 45 Font cf(Font::CreateFont(L"Arial", 16)); |
| 43 ASSERT_EQ(cf.GetExpectedTextWidth(0), 0); | 46 ASSERT_EQ(cf.GetExpectedTextWidth(0), 0); |
| 44 ASSERT_GT(cf.GetExpectedTextWidth(1), cf.GetExpectedTextWidth(0)); | 47 ASSERT_GT(cf.GetExpectedTextWidth(1), cf.GetExpectedTextWidth(0)); |
| 45 ASSERT_GT(cf.GetExpectedTextWidth(2), cf.GetExpectedTextWidth(1)); | 48 ASSERT_GT(cf.GetExpectedTextWidth(2), cf.GetExpectedTextWidth(1)); |
| 46 ASSERT_GT(cf.GetExpectedTextWidth(3), cf.GetExpectedTextWidth(2)); | 49 ASSERT_GT(cf.GetExpectedTextWidth(3), cf.GetExpectedTextWidth(2)); |
| 47 } | 50 } |
| 48 | 51 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 67 TEST_F(FontTest, DeriveFontKeepsOriginalSizeIfHeightOk) { | 70 TEST_F(FontTest, DeriveFontKeepsOriginalSizeIfHeightOk) { |
| 68 // This creates font of height -8. | 71 // This creates font of height -8. |
| 69 Font cf(Font::CreateFont(L"Arial", 6)); | 72 Font cf(Font::CreateFont(L"Arial", 6)); |
| 70 Font derived_font = cf.DeriveFont(-2); | 73 Font derived_font = cf.DeriveFont(-2); |
| 71 LOGFONT font_info; | 74 LOGFONT font_info; |
| 72 GetObject(derived_font.hfont(), sizeof(LOGFONT), &font_info); | 75 GetObject(derived_font.hfont(), sizeof(LOGFONT), &font_info); |
| 73 EXPECT_EQ(-6, font_info.lfHeight); | 76 EXPECT_EQ(-6, font_info.lfHeight); |
| 74 } | 77 } |
| 75 #endif | 78 #endif |
| 76 } // anonymous namespace | 79 } // anonymous namespace |
| OLD | NEW |