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