OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/render_text.h" | 5 #include "ui/gfx/render_text.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 2322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2333 | 2333 |
2334 render_text->SetMinLineHeight(default_size.height() / 2); | 2334 render_text->SetMinLineHeight(default_size.height() / 2); |
2335 EXPECT_EQ(default_size.ToString(), render_text->GetStringSizeF().ToString()); | 2335 EXPECT_EQ(default_size.ToString(), render_text->GetStringSizeF().ToString()); |
2336 | 2336 |
2337 render_text->SetMinLineHeight(default_size.height() * 2); | 2337 render_text->SetMinLineHeight(default_size.height() * 2); |
2338 SizeF taller_size = render_text->GetStringSizeF(); | 2338 SizeF taller_size = render_text->GetStringSizeF(); |
2339 EXPECT_EQ(default_size.height() * 2, taller_size.height()); | 2339 EXPECT_EQ(default_size.height() * 2, taller_size.height()); |
2340 EXPECT_EQ(default_size.width(), taller_size.width()); | 2340 EXPECT_EQ(default_size.width(), taller_size.width()); |
2341 } | 2341 } |
2342 | 2342 |
2343 // Check that, for Latin characters, typesetting text in the default fonts and | |
2344 // sizes does not discover any glyphs that would exceed the line spacing | |
2345 // recommended by gfx::Font. | |
2346 // Disabled since this relies on machine configuration. http://crbug.com/701241. | |
sky
2017/03/20 16:33:11
The bug points at the harmony bug, which isn't at
tapted
2017/03/20 22:31:42
The plan would be to bring this up at the same tim
| |
2347 TEST_P(RenderTextTest, DISABLED_DefaultLineHeights) { | |
2348 RenderText* render_text = GetRenderText(); | |
2349 render_text->SetText( | |
2350 ASCIIToUTF16("A quick brown fox jumped over the lazy dog!")); | |
2351 | |
2352 #if defined(OS_MACOSX) | |
2353 const FontList body2_font = FontList().DeriveWithSizeDelta(-1); | |
2354 #else | |
2355 const FontList body2_font; | |
2356 #endif | |
2357 | |
2358 const FontList headline_font = body2_font.DeriveWithSizeDelta(8); | |
2359 const FontList title_font = body2_font.DeriveWithSizeDelta(3); | |
2360 const FontList body1_font = body2_font.DeriveWithSizeDelta(1); | |
2361 #if defined(OS_WIN) | |
2362 const FontList button_font = | |
2363 body2_font.DeriveWithWeight(gfx::Font::Weight::BOLD); | |
2364 #else | |
2365 const FontList button_font = | |
2366 body2_font.DeriveWithWeight(gfx::Font::Weight::MEDIUM); | |
2367 #endif | |
2368 | |
2369 EXPECT_EQ(12, body2_font.GetFontSize()); | |
2370 EXPECT_EQ(20, headline_font.GetFontSize()); | |
2371 EXPECT_EQ(15, title_font.GetFontSize()); | |
2372 EXPECT_EQ(13, body1_font.GetFontSize()); | |
2373 EXPECT_EQ(12, button_font.GetFontSize()); | |
2374 | |
2375 for (const auto& font : | |
2376 {headline_font, title_font, body1_font, body2_font, button_font}) { | |
2377 render_text->SetFontList(font); | |
2378 EXPECT_EQ(font.GetHeight(), render_text->GetStringSizeF().height()); | |
2379 } | |
2380 } | |
2381 | |
2343 TEST_P(RenderTextTest, SetFontList) { | 2382 TEST_P(RenderTextTest, SetFontList) { |
2344 RenderText* render_text = GetRenderText(); | 2383 RenderText* render_text = GetRenderText(); |
2345 render_text->SetFontList( | 2384 render_text->SetFontList( |
2346 FontList(base::StringPrintf("Arial,%s, 13px", kSymbolFontName))); | 2385 FontList(base::StringPrintf("Arial,%s, 13px", kSymbolFontName))); |
2347 const std::vector<Font>& fonts = render_text->font_list().GetFonts(); | 2386 const std::vector<Font>& fonts = render_text->font_list().GetFonts(); |
2348 ASSERT_EQ(2U, fonts.size()); | 2387 ASSERT_EQ(2U, fonts.size()); |
2349 EXPECT_EQ("Arial", fonts[0].GetFontName()); | 2388 EXPECT_EQ("Arial", fonts[0].GetFontName()); |
2350 EXPECT_EQ(kSymbolFontName, fonts[1].GetFontName()); | 2389 EXPECT_EQ(kSymbolFontName, fonts[1].GetFontName()); |
2351 EXPECT_EQ(13, render_text->font_list().GetFontSize()); | 2390 EXPECT_EQ(13, render_text->font_list().GetFontSize()); |
2352 } | 2391 } |
(...skipping 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4384 ::testing::Values(RENDER_TEXT_HARFBUZZ), | 4423 ::testing::Values(RENDER_TEXT_HARFBUZZ), |
4385 PrintRenderTextBackend()); | 4424 PrintRenderTextBackend()); |
4386 #endif | 4425 #endif |
4387 | 4426 |
4388 INSTANTIATE_TEST_CASE_P(, | 4427 INSTANTIATE_TEST_CASE_P(, |
4389 RenderTextHarfBuzzTest, | 4428 RenderTextHarfBuzzTest, |
4390 ::testing::Values(RENDER_TEXT_HARFBUZZ), | 4429 ::testing::Values(RENDER_TEXT_HARFBUZZ), |
4391 PrintRenderTextBackend()); | 4430 PrintRenderTextBackend()); |
4392 | 4431 |
4393 } // namespace gfx | 4432 } // namespace gfx |
OLD | NEW |