diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-13 16:43:03 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-13 16:43:03 +0000 |
commit | c6ac841f51c0b884b38e917ac30b1dfde0dc43a7 (patch) | |
tree | 2b490ffa6795f72e7232d658b766785f0de64e38 /gfx/font_unittest.cc | |
parent | 6b32b95cff99ee72fd7824237ae5070263e5c496 (diff) | |
download | chromium_src-c6ac841f51c0b884b38e917ac30b1dfde0dc43a7.zip chromium_src-c6ac841f51c0b884b38e917ac30b1dfde0dc43a7.tar.gz chromium_src-c6ac841f51c0b884b38e917ac30b1dfde0dc43a7.tar.bz2 |
Rework gfx::Font by moving platform-specific code into inner classes.
gfx::Font is a platform-neutral API shim that exists as a wrapper object to allow for the creation and lifetime of gfx::Font objects to remain consistent with past usage.
gfx::PlatformFont is an interface implemented by the platform-specific inner classes (gfx::PlatformFontWin,Mac,Gtk).
BUG=none
TEST=existing unittests
Review URL: http://codereview.chromium.org/3083022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56040 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx/font_unittest.cc')
-rw-r--r-- | gfx/font_unittest.cc | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/gfx/font_unittest.cc b/gfx/font_unittest.cc index 6e63951..d2eda1c 100644 --- a/gfx/font_unittest.cc +++ b/gfx/font_unittest.cc @@ -14,35 +14,35 @@ class FontTest : public testing::Test { }; TEST_F(FontTest, LoadArial) { - Font cf(Font::CreateFont(L"Arial", 16)); - ASSERT_TRUE(cf.nativeFont()); - ASSERT_EQ(cf.style(), Font::NORMAL); - ASSERT_EQ(cf.FontSize(), 16); - ASSERT_EQ(cf.FontName(), L"Arial"); + Font cf(L"Arial", 16); + ASSERT_TRUE(cf.GetNativeFont()); + ASSERT_EQ(cf.GetStyle(), Font::NORMAL); + ASSERT_EQ(cf.GetFontSize(), 16); + ASSERT_EQ(cf.GetFontName(), L"Arial"); } TEST_F(FontTest, LoadArialBold) { - Font cf(Font::CreateFont(L"Arial", 16)); + Font cf(L"Arial", 16); Font bold(cf.DeriveFont(0, Font::BOLD)); - ASSERT_TRUE(bold.nativeFont()); - ASSERT_EQ(bold.style(), Font::BOLD); + ASSERT_TRUE(bold.GetNativeFont()); + ASSERT_EQ(bold.GetStyle(), Font::BOLD); } TEST_F(FontTest, Ascent) { - Font cf(Font::CreateFont(L"Arial", 16)); - ASSERT_GT(cf.baseline(), 2); - ASSERT_LE(cf.baseline(), 22); + Font cf(L"Arial", 16); + ASSERT_GT(cf.GetBaseline(), 2); + ASSERT_LE(cf.GetBaseline(), 22); } TEST_F(FontTest, Height) { - Font cf(Font::CreateFont(L"Arial", 16)); - ASSERT_GE(cf.height(), 16); + Font cf(L"Arial", 16); + ASSERT_GE(cf.GetHeight(), 16); // TODO(akalin): Figure out why height is so large on Linux. - ASSERT_LE(cf.height(), 26); + ASSERT_LE(cf.GetHeight(), 26); } TEST_F(FontTest, AvgWidths) { - Font cf(Font::CreateFont(L"Arial", 16)); + Font cf(L"Arial", 16); ASSERT_EQ(cf.GetExpectedTextWidth(0), 0); ASSERT_GT(cf.GetExpectedTextWidth(1), cf.GetExpectedTextWidth(0)); ASSERT_GT(cf.GetExpectedTextWidth(2), cf.GetExpectedTextWidth(1)); @@ -50,7 +50,7 @@ TEST_F(FontTest, AvgWidths) { } TEST_F(FontTest, Widths) { - Font cf(Font::CreateFont(L"Arial", 16)); + Font cf(L"Arial", 16); ASSERT_EQ(cf.GetStringWidth(L""), 0); ASSERT_GT(cf.GetStringWidth(L"a"), cf.GetStringWidth(L"")); ASSERT_GT(cf.GetStringWidth(L"ab"), cf.GetStringWidth(L"a")); @@ -61,20 +61,20 @@ TEST_F(FontTest, Widths) { // http://crbug.com/46733 TEST_F(FontTest, FAILS_DeriveFontResizesIfSizeTooSmall) { // This creates font of height -8. - Font cf(Font::CreateFont(L"Arial", 6)); + Font cf(L"Arial", 6); Font derived_font = cf.DeriveFont(-4); LOGFONT font_info; - GetObject(derived_font.hfont(), sizeof(LOGFONT), &font_info); + GetObject(derived_font.GetNativeFont(), sizeof(LOGFONT), &font_info); EXPECT_EQ(-5, font_info.lfHeight); } TEST_F(FontTest, DeriveFontKeepsOriginalSizeIfHeightOk) { // This creates font of height -8. - Font cf(Font::CreateFont(L"Arial", 6)); + Font cf(L"Arial", 6); Font derived_font = cf.DeriveFont(-2); LOGFONT font_info; - GetObject(derived_font.hfont(), sizeof(LOGFONT), &font_info); + GetObject(derived_font.GetNativeFont(), sizeof(LOGFONT), &font_info); EXPECT_EQ(-6, font_info.lfHeight); } #endif -} // anonymous namespace +} // namespace |