| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "app/gfx/chrome_font.h" | |
| 6 | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 | |
| 9 namespace { | |
| 10 | |
| 11 using gfx::Font; | |
| 12 | |
| 13 class FontTest : public testing::Test { | |
| 14 }; | |
| 15 | |
| 16 TEST_F(FontTest, LoadArial) { | |
| 17 Font cf(Font::CreateFont(L"Arial", 16)); | |
| 18 ASSERT_TRUE(cf.nativeFont()); | |
| 19 ASSERT_EQ(cf.style(), Font::NORMAL); | |
| 20 ASSERT_EQ(cf.FontSize(), 16); | |
| 21 ASSERT_EQ(cf.FontName(), L"Arial"); | |
| 22 } | |
| 23 | |
| 24 TEST_F(FontTest, LoadArialBold) { | |
| 25 Font cf(Font::CreateFont(L"Arial", 16)); | |
| 26 Font bold(cf.DeriveFont(0, Font::BOLD)); | |
| 27 ASSERT_TRUE(bold.nativeFont()); | |
| 28 ASSERT_EQ(bold.style(), Font::BOLD); | |
| 29 } | |
| 30 | |
| 31 TEST_F(FontTest, Ascent) { | |
| 32 Font cf(Font::CreateFont(L"Arial", 16)); | |
| 33 ASSERT_GT(cf.baseline(), 2); | |
| 34 ASSERT_LT(cf.baseline(), 20); | |
| 35 } | |
| 36 | |
| 37 TEST_F(FontTest, Height) { | |
| 38 Font cf(Font::CreateFont(L"Arial", 16)); | |
| 39 ASSERT_GT(cf.baseline(), 2); | |
| 40 ASSERT_LT(cf.baseline(), 20); | |
| 41 } | |
| 42 | |
| 43 TEST_F(FontTest, AvgWidths) { | |
| 44 Font cf(Font::CreateFont(L"Arial", 16)); | |
| 45 ASSERT_EQ(cf.GetExpectedTextWidth(0), 0); | |
| 46 ASSERT_GT(cf.GetExpectedTextWidth(1), cf.GetExpectedTextWidth(0)); | |
| 47 ASSERT_GT(cf.GetExpectedTextWidth(2), cf.GetExpectedTextWidth(1)); | |
| 48 ASSERT_GT(cf.GetExpectedTextWidth(3), cf.GetExpectedTextWidth(2)); | |
| 49 } | |
| 50 | |
| 51 TEST_F(FontTest, Widths) { | |
| 52 Font cf(Font::CreateFont(L"Arial", 16)); | |
| 53 ASSERT_EQ(cf.GetStringWidth(L""), 0); | |
| 54 ASSERT_GT(cf.GetStringWidth(L"a"), cf.GetStringWidth(L"")); | |
| 55 ASSERT_GT(cf.GetStringWidth(L"ab"), cf.GetStringWidth(L"a")); | |
| 56 ASSERT_GT(cf.GetStringWidth(L"abc"), cf.GetStringWidth(L"ab")); | |
| 57 } | |
| 58 | |
| 59 } // anonymous namespace | |
| OLD | NEW |