chromium/ui/gfx/platform_font_skia_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/platform_font_skia.h"

#include <string>

#include "base/check_op.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/notreached.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/font.h"
#include "ui/gfx/font_names_testing.h"
#include "ui/gfx/font_render_params.h"

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

#if BUILDFLAG(IS_LINUX)
#include "ui/linux/fake_linux_ui.h"
#endif

namespace gfx {

#if BUILDFLAG(IS_LINUX)
// Implementation of LinuxUi used to control the default font description.
class TestFontDelegate : public ui::FakeLinuxUi {};

class PlatformFontSkiaTest : public testing::Test {};

// Test that PlatformFontSkia's default constructor initializes the instance
// with the correct parameters.
TEST_F(PlatformFontSkiaTest, DefaultFont) {}
#endif  // BUILDFLAG(IS_LINUX)

TEST(PlatformFontSkiaRenderParamsTest, DefaultFontRenderParams) {}

#if BUILDFLAG(IS_WIN)
TEST(PlatformFontSkiaOnWindowsTest, SystemFont) {
  // Ensures that the font styles are kept while creating the default font.
  gfx::Font system_font = win::GetDefaultSystemFont();
  gfx::Font default_font;

  EXPECT_EQ(system_font.GetFontName(), default_font.GetFontName());
  EXPECT_EQ(system_font.GetFontSize(), default_font.GetFontSize());
  EXPECT_EQ(system_font.GetStyle(), default_font.GetStyle());
  EXPECT_EQ(system_font.GetWeight(), default_font.GetWeight());
  EXPECT_EQ(system_font.GetHeight(), default_font.GetHeight());
  EXPECT_EQ(system_font.GetBaseline(), default_font.GetBaseline());
  EXPECT_EQ(system_font.GetBaseline(), default_font.GetBaseline());
  EXPECT_EQ(system_font.GetFontRenderParams(),
            default_font.GetFontRenderParams());
}
#endif  // BUILDFLAG(IS_WIN)

}  // namespace gfx