Commit ffd1f793 authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Add unittests for default font constructor.

This CL is adding a test to cover:
  Font::Font(...)
  PlatformFont::CreateDefault(...)

The default constructor was not covered by any unittests. This was found
while doing the migration from PlatformFontWin to PlatformFontSkia.

This CL is also restricting the use Font::platform_font(...) to windows.
This function will be removed as soon as the migration is completed.

R=robliao@chromium.org, asvitkine@chromium.org
CC=benck@google.com

Bug: 944227
Change-Id: Ib9a77c412966c3ebff81dfbf5340a762f69dc6e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1642816
Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666373}
parent 104fd104
......@@ -124,9 +124,11 @@ class GFX_EXPORT Font {
NativeFont GetNativeFont() const;
#endif
#if defined(OS_WIN)
// Raw access to the underlying platform font implementation. Can be
// static_cast to a known implementation type if needed.
PlatformFont* platform_font() const { return platform_font_.get(); }
#endif
private:
// Wrapped platform font implementation.
......
......@@ -13,7 +13,6 @@
#include "ui/gfx/font_names_testing.h"
#if defined(OS_WIN)
#include "ui/gfx/platform_font_win.h"
#include "ui/gfx/system_fonts_win.h"
#endif
......@@ -22,6 +21,19 @@ namespace {
using FontTest = testing::Test;
TEST_F(FontTest, DefaultFont) {
Font cf;
EXPECT_EQ(cf.GetStyle(), Font::NORMAL);
EXPECT_EQ(cf.GetWeight(), Font::Weight::NORMAL);
// Ensures that font metrics are generated. Some fonts backends do not provide
// some metrics (e.g. DWrite do not produce average character width).
EXPECT_GT(cf.GetFontSize(), 0);
EXPECT_GT(cf.GetHeight(), 0);
EXPECT_GT(cf.GetBaseline(), 0);
EXPECT_GT(cf.GetCapHeight(), 0);
EXPECT_GT(cf.GetExpectedTextWidth(1), 0);
}
TEST_F(FontTest, LoadArial) {
Font cf(kTestFontName, 16);
#if defined(OS_MACOSX) || defined(OS_IOS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment