Commit 8d3fdfc6 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Enable two disabled font metric tests on Android.

The tests currently assume that the normal and CJK fonts have different metrics.
On Android, this is not true for all platforms we support.  The tests still have
some value when run with fonts with identical metrics, so modify the test
expectations slightly to work in that case and enable these tests.

Bug: 865540
Change-Id: I6cd98a254f9ae0e6c6a9818e37c9ae69ca954f13
Reviewed-on: https://chromium-review.googlesource.com/c/1343531
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610115}
parent a793efbd
......@@ -232,13 +232,7 @@ TEST(FontListTest, Fonts_DeriveWithSizeDelta) {
EXPECT_EQ("Courier New|13|italic|normal", FontToString(derived_fonts[1]));
}
// TODO(865540): Enable this on android.
#if defined(OS_ANDROID)
#define MAYBE_Fonts_GetHeight_GetBaseline DISABLED_Fonts_GetHeight_GetBaseline
#else
#define MAYBE_Fonts_GetHeight_GetBaseline Fonts_GetHeight_GetBaseline
#endif
TEST(FontListTest, MAYBE_Fonts_GetHeight_GetBaseline) {
TEST(FontListTest, Fonts_GetHeight_GetBaseline) {
// If a font list has only one font, the height and baseline must be the same.
Font font1(kTestFontName, 16);
ASSERT_EQ(base::ToLowerASCII(kTestFontName),
......@@ -249,12 +243,11 @@ TEST(FontListTest, MAYBE_Fonts_GetHeight_GetBaseline) {
// If there are two different fonts, the font list returns the max value
// for the baseline (ascent) and height.
// NOTE: On most platforms, kCJKFontName has different metrics than
// kTestFontName, but on Android it does not.
Font font2(kCJKFontName, 16);
ASSERT_EQ(base::ToLowerASCII(kCJKFontName),
base::ToLowerASCII(font2.GetActualFontNameForTesting()));
EXPECT_NE(font1.GetBaseline(), font2.GetBaseline());
// TODO(ananta): Find a size and font pair with reliably distinct descents.
EXPECT_NE(font1.GetHeight(), font2.GetHeight());
std::vector<Font> fonts;
fonts.push_back(font1);
fonts.push_back(font2);
......
......@@ -2469,26 +2469,15 @@ TEST_F(RenderTextTest, StringSizeEmptyString) {
EXPECT_EQ(font_list.GetBaseline(), render_text->GetBaseline());
}
// TODO(865540): Find two system fonts on Android with different baseline and
// different height.
// See also: FontListTest::Fonts_GetHeight_GetBaseline.
#if defined(OS_ANDROID)
#define MAYBE_StringSizeRespectsFontListMetrics \
DISABLED_StringSizeRespectsFontListMetrics
#else
#define MAYBE_StringSizeRespectsFontListMetrics \
StringSizeRespectsFontListMetrics
#endif
TEST_F(RenderTextTest, MAYBE_StringSizeRespectsFontListMetrics) {
// Check that the test font and the CJK font have different font metrics.
TEST_F(RenderTextTest, StringSizeRespectsFontListMetrics) {
// NOTE: On most platforms, kCJKFontName has different metrics than
// kTestFontName, but on Android it does not.
Font test_font(kTestFontName, 16);
ASSERT_EQ(base::ToLowerASCII(kTestFontName),
base::ToLowerASCII(test_font.GetActualFontNameForTesting()));
Font cjk_font(kCJKFontName, 16);
ASSERT_EQ(base::ToLowerASCII(kCJKFontName),
base::ToLowerASCII(cjk_font.GetActualFontNameForTesting()));
EXPECT_NE(test_font.GetHeight(), cjk_font.GetHeight());
EXPECT_NE(test_font.GetBaseline(), cjk_font.GetBaseline());
// "a" should be rendered with the test font, not with the CJK font.
const char* test_font_text = "a";
// "円" (U+5168 Han character YEN) should render with the CJK font, not
......@@ -2503,8 +2492,8 @@ TEST_F(RenderTextTest, MAYBE_StringSizeRespectsFontListMetrics) {
std::swap(smaller_font, larger_font);
std::swap(smaller_font_text, larger_font_text);
}
ASSERT_LT(smaller_font.GetHeight(), larger_font.GetHeight());
ASSERT_LT(smaller_font.GetBaseline(), larger_font.GetBaseline());
ASSERT_LE(smaller_font.GetHeight(), larger_font.GetHeight());
ASSERT_LE(smaller_font.GetBaseline(), larger_font.GetBaseline());
// Check |smaller_font_text| is rendered with the smaller font.
RenderText* render_text = GetRenderText();
......@@ -2531,8 +2520,8 @@ TEST_F(RenderTextTest, MAYBE_StringSizeRespectsFontListMetrics) {
EXPECT_STRCASEEQ(
render_text->GetFontSpansForTesting()[0].first.GetFontName().c_str(),
smaller_font.GetFontName().c_str());
EXPECT_LT(smaller_font.GetHeight(), render_text->GetStringSize().height());
EXPECT_LT(smaller_font.GetBaseline(), render_text->GetBaseline());
EXPECT_LE(smaller_font.GetHeight(), render_text->GetStringSize().height());
EXPECT_LE(smaller_font.GetBaseline(), render_text->GetBaseline());
EXPECT_EQ(font_list.GetHeight(), render_text->GetStringSize().height());
EXPECT_EQ(font_list.GetBaseline(), render_text->GetBaseline());
}
......
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