#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) { … }
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
TEST_F(FontTest, WeightConversion) { … }
}
}