| 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 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 TEST_F(RenderTextTest, SetFontList) { | 1756 TEST_F(RenderTextTest, SetFontList) { |
| 1757 std::unique_ptr<RenderText> render_text(RenderText::CreateInstance()); | 1757 std::unique_ptr<RenderText> render_text(RenderText::CreateInstance()); |
| 1758 render_text->SetFontList(FontList("Arial,Symbol, 13px")); | 1758 render_text->SetFontList(FontList("Arial,Symbol, 13px")); |
| 1759 const std::vector<Font>& fonts = render_text->font_list().GetFonts(); | 1759 const std::vector<Font>& fonts = render_text->font_list().GetFonts(); |
| 1760 ASSERT_EQ(2U, fonts.size()); | 1760 ASSERT_EQ(2U, fonts.size()); |
| 1761 EXPECT_EQ("Arial", fonts[0].GetFontName()); | 1761 EXPECT_EQ("Arial", fonts[0].GetFontName()); |
| 1762 EXPECT_EQ("Symbol", fonts[1].GetFontName()); | 1762 EXPECT_EQ("Symbol", fonts[1].GetFontName()); |
| 1763 EXPECT_EQ(13, render_text->font_list().GetFontSize()); | 1763 EXPECT_EQ(13, render_text->font_list().GetFontSize()); |
| 1764 } | 1764 } |
| 1765 | 1765 |
| 1766 TEST_F(RenderTextTest, StringSizeBoldWidth) { | 1766 // http://crbug/624513 |
| 1767 #if defined(OS_WIN) |
| 1768 #define MAYBE_StringSizeBoldWidth DISABLED_StringSizeBoldWidth |
| 1769 #else |
| 1770 #define MAYBE_StringSizeBoldWidth StringSizeBoldWidth |
| 1771 #endif |
| 1772 TEST_F(RenderTextTest, MAYBE_StringSizeBoldWidth) { |
| 1767 // TODO(mboc): Add some unittests for other weights (currently not | 1773 // TODO(mboc): Add some unittests for other weights (currently not |
| 1768 // implemented because of test system font configuration). | 1774 // implemented because of test system font configuration). |
| 1769 std::unique_ptr<RenderText> render_text(RenderText::CreateInstance()); | 1775 std::unique_ptr<RenderText> render_text(RenderText::CreateInstance()); |
| 1770 render_text->SetText(UTF8ToUTF16("Hello World")); | 1776 render_text->SetText(UTF8ToUTF16("Hello World")); |
| 1771 | 1777 |
| 1772 const int plain_width = render_text->GetStringSize().width(); | 1778 const int plain_width = render_text->GetStringSize().width(); |
| 1773 EXPECT_GT(plain_width, 0); | 1779 EXPECT_GT(plain_width, 0); |
| 1774 | 1780 |
| 1775 // Apply a bold style and check that the new width is greater. | 1781 // Apply a bold style and check that the new width is greater. |
| 1776 render_text->SetWeight(Font::Weight::BOLD); | 1782 render_text->SetWeight(Font::Weight::BOLD); |
| (...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3148 | 3154 |
| 3149 // Korean character "han". | 3155 // Korean character "han". |
| 3150 render_text.SetText(WideToUTF16(L"\xd55c")); | 3156 render_text.SetText(WideToUTF16(L"\xd55c")); |
| 3151 render_text.EnsureLayout(); | 3157 render_text.EnsureLayout(); |
| 3152 internal::TextRunList* run_list = render_text.GetRunList(); | 3158 internal::TextRunList* run_list = render_text.GetRunList(); |
| 3153 ASSERT_EQ(1U, run_list->size()); | 3159 ASSERT_EQ(1U, run_list->size()); |
| 3154 EXPECT_EQ(0U, run_list->runs()[0]->CountMissingGlyphs()); | 3160 EXPECT_EQ(0U, run_list->runs()[0]->CountMissingGlyphs()); |
| 3155 } | 3161 } |
| 3156 #endif // !defined(OS_LINUX) | 3162 #endif // !defined(OS_LINUX) |
| 3157 | 3163 |
| 3164 // http://crbug/624513 |
| 3165 #if defined(OS_WIN) |
| 3166 #define MAYBE_TextDoesntClip DISABLED_TextDoesntClip |
| 3167 #else |
| 3168 #define MAYBE_TextDoesntClip TextDoesntClip |
| 3169 #endif |
| 3158 // Ensure that the width reported by RenderText is sufficient for drawing. Draws | 3170 // Ensure that the width reported by RenderText is sufficient for drawing. Draws |
| 3159 // to a canvas and checks if any pixel beyond the bounding rectangle is colored. | 3171 // to a canvas and checks if any pixel beyond the bounding rectangle is colored. |
| 3160 TEST_F(RenderTextTest, TextDoesntClip) { | 3172 TEST_F(RenderTextTest, MAYBE_TextDoesntClip) { |
| 3161 const wchar_t* kTestStrings[] = { | 3173 const wchar_t* kTestStrings[] = { |
| 3162 L" ", | 3174 L" ", |
| 3163 // TODO(dschuyler): Underscores draw outside GetStringSize; | 3175 // TODO(dschuyler): Underscores draw outside GetStringSize; |
| 3164 // crbug.com/459812. This appears to be a preexisting issue that wasn't | 3176 // crbug.com/459812. This appears to be a preexisting issue that wasn't |
| 3165 // revealed by the prior unit tests. | 3177 // revealed by the prior unit tests. |
| 3166 // L"TEST_______", | 3178 // L"TEST_______", |
| 3167 L"TEST some stuff", | 3179 L"TEST some stuff", |
| 3168 L"WWWWWWWWWW", | 3180 L"WWWWWWWWWW", |
| 3169 L"gAXAXAXAXAXAXA", | 3181 L"gAXAXAXAXAXAXA", |
| 3170 // TODO(dschuyler): A-Ring draws outside GetStringSize; crbug.com/459812. | 3182 // TODO(dschuyler): A-Ring draws outside GetStringSize; crbug.com/459812. |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3419 EXPECT_FALSE(backend.paint().isLCDRenderText()); | 3431 EXPECT_FALSE(backend.paint().isLCDRenderText()); |
| 3420 backend.GetHarfbuzzRunList()->runs()[0]->render_params.subpixel_rendering = | 3432 backend.GetHarfbuzzRunList()->runs()[0]->render_params.subpixel_rendering = |
| 3421 FontRenderParams::SUBPIXEL_RENDERING_RGB; | 3433 FontRenderParams::SUBPIXEL_RENDERING_RGB; |
| 3422 backend.DrawVisualText(); | 3434 backend.DrawVisualText(); |
| 3423 #endif | 3435 #endif |
| 3424 EXPECT_FALSE(backend.paint().isLCDRenderText()); | 3436 EXPECT_FALSE(backend.paint().isLCDRenderText()); |
| 3425 } | 3437 } |
| 3426 } | 3438 } |
| 3427 | 3439 |
| 3428 } // namespace gfx | 3440 } // namespace gfx |
| OLD | NEW |