Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Side by Side Diff: app/gfx/chrome_font_unittest.cc

Issue 113443: ChromeCanvas->gfx::Canvas (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « app/gfx/chrome_font_skia.cc ('k') | app/gfx/chrome_font_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « app/gfx/chrome_font_skia.cc ('k') | app/gfx/chrome_font_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698