chromium/ui/gfx/font_unittest.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/gfx/font.h"

#include <string>

#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/font_names_testing.h"

#if BUILDFLAG(IS_WIN)
#include "ui/gfx/system_fonts_win.h"
#endif

namespace gfx {
namespace {

class FontTest : public testing::Test {};

TEST_F(FontTest, DefaultFont) {}

TEST_F(FontTest, LoadArial) {}

TEST_F(FontTest, LoadArialBold) {}

TEST_F(FontTest, Ascent) {}

TEST_F(FontTest, Height) {}

TEST_F(FontTest, CapHeight) {}

TEST_F(FontTest, AvgWidths) {}

// Check that fonts used for testing are installed and enabled. On Mac
// fonts may be installed but still need enabling in Font Book.app.
// http://crbug.com/347429
TEST_F(FontTest, GetActualFontName) {}

TEST_F(FontTest, DeriveFont) {}

#if BUILDFLAG(IS_WIN)
TEST_F(FontTest, DeriveResizesIfSizeTooSmall) {
  Font cf(kTestFontName, 8);
  gfx::win::SetGetMinimumFontSizeCallback([] { return 5; });

  Font derived_font = cf.Derive(-4, cf.GetStyle(), cf.GetWeight());
  EXPECT_EQ(5, derived_font.GetFontSize());
}

TEST_F(FontTest, DeriveKeepsOriginalSizeIfHeightOk) {
  Font cf(kTestFontName, 8);
  gfx::win::SetGetMinimumFontSizeCallback([] { return 5; });

  Font derived_font = cf.Derive(-2, cf.GetStyle(), cf.GetWeight());
  EXPECT_EQ(6, derived_font.GetFontSize());
}
#endif  // BUILDFLAG(IS_WIN)

TEST_F(FontTest, WeightConversion) {}

}  // namespace
}  // namespace gfx