diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-15 07:37:29 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-15 07:37:29 +0000 |
commit | 82522511b7921e8c61742ebd80a4c674c56e7e48 (patch) | |
tree | 381d71de2b9c7b99675e6f2b4523ae0876c72ce8 /app/gfx/font_unittest.cc | |
parent | 631cf822bd6e64cf469544b42c9975f5602c29a6 (diff) | |
download | chromium_src-82522511b7921e8c61742ebd80a4c674c56e7e48.zip chromium_src-82522511b7921e8c61742ebd80a4c674c56e7e48.tar.gz chromium_src-82522511b7921e8c61742ebd80a4c674c56e7e48.tar.bz2 |
ChromeCanvas->gfx::Canvas
Rename files too.
TBR=brettw
http://crbug.com/11387
Review URL: http://codereview.chromium.org/113443
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16148 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/gfx/font_unittest.cc')
-rw-r--r-- | app/gfx/font_unittest.cc | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/app/gfx/font_unittest.cc b/app/gfx/font_unittest.cc new file mode 100644 index 0000000..3a13e2f6 --- /dev/null +++ b/app/gfx/font_unittest.cc @@ -0,0 +1,59 @@ +// 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 "app/gfx/font.h" + +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +using gfx::Font; + +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"); +} + +TEST_F(FontTest, LoadArialBold) { + Font cf(Font::CreateFont(L"Arial", 16)); + Font bold(cf.DeriveFont(0, Font::BOLD)); + ASSERT_TRUE(bold.nativeFont()); + ASSERT_EQ(bold.style(), Font::BOLD); +} + +TEST_F(FontTest, Ascent) { + Font cf(Font::CreateFont(L"Arial", 16)); + ASSERT_GT(cf.baseline(), 2); + ASSERT_LT(cf.baseline(), 20); +} + +TEST_F(FontTest, Height) { + Font cf(Font::CreateFont(L"Arial", 16)); + ASSERT_GT(cf.baseline(), 2); + ASSERT_LT(cf.baseline(), 20); +} + +TEST_F(FontTest, AvgWidths) { + Font cf(Font::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(FontTest, Widths) { + Font cf(Font::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 |