diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-12 01:52:25 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-12 01:52:25 +0000 |
commit | 7f4bfe196f0976c7151de206601860b47f913fcb (patch) | |
tree | c9596f2808f2ea68c4b9629faa10833bbdb1e5e3 /chrome/common/gfx/chrome_font_unittest.cc | |
parent | f95b68396b06021b5aac4f7f1f4d15cb67b0414a (diff) | |
download | chromium_src-7f4bfe196f0976c7151de206601860b47f913fcb.zip chromium_src-7f4bfe196f0976c7151de206601860b47f913fcb.tar.gz chromium_src-7f4bfe196f0976c7151de206601860b47f913fcb.tar.bz2 |
...
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6871 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/gfx/chrome_font_unittest.cc')
-rw-r--r-- | chrome/common/gfx/chrome_font_unittest.cc | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/chrome/common/gfx/chrome_font_unittest.cc b/chrome/common/gfx/chrome_font_unittest.cc new file mode 100644 index 0000000..d0b61d2 --- /dev/null +++ b/chrome/common/gfx/chrome_font_unittest.cc @@ -0,0 +1,57 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/gfx/chrome_font.h" + +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +class ChromeFontTest : public testing::Test { +}; + +TEST_F(ChromeFontTest, LoadArial) { + ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16)); + ASSERT_TRUE(cf.nativeFont()); + ASSERT_EQ(cf.style(), ChromeFont::NORMAL); + ASSERT_EQ(cf.FontSize(), 16); + ASSERT_EQ(cf.FontName(), L"Arial"); +} + +TEST_F(ChromeFontTest, LoadArialBold) { + ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16)); + ChromeFont bold(cf.DeriveFont(0, ChromeFont::BOLD)); + ASSERT_TRUE(bold.nativeFont()); + ASSERT_EQ(bold.style(), ChromeFont::BOLD); +} + +TEST_F(ChromeFontTest, Ascent) { + ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16)); + ASSERT_GT(cf.baseline(), 2); + ASSERT_LT(cf.baseline(), 20); +} + +TEST_F(ChromeFontTest, Height) { + ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16)); + ASSERT_GT(cf.baseline(), 2); + ASSERT_LT(cf.baseline(), 20); +} + +TEST_F(ChromeFontTest, AvgWidths) { + ChromeFont cf(ChromeFont::CreateFont(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)); + ASSERT_GT(cf.GetExpectedTextWidth(3), cf.GetExpectedTextWidth(2)); +} + +TEST_F(ChromeFontTest, Widths) { + ChromeFont cf(ChromeFont::CreateFont(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")); + ASSERT_GT(cf.GetStringWidth(L"abc"), cf.GetStringWidth(L"ab")); +} + +} // anonymous namespace |